我正在尝试使用此处的代码,但不确定如何正确调整它。 https://communities.sas.com/thread/33654?start=0&tstart=0
我正在尝试将 51 个 SAS 数据集导出到 CSV 文件,以便可以将它们导入 R。这是我拥有的宏代码(不起作用):
libname g 'C:\mylibrary';
%macro export(libname, numvars= &numvars.);
%do i= 1 %to &numvars.;
proc export data=&libname.StateZip&i
DBMS=CSV REPLACE
outfile= "&libname.StateZip&i.csv";
run;
%end;
%mend;
%export(&g, numvars= 51);
这是我收到的错误消息:
NOTE: Writing TAGSETS.SASREPORT12(EGSR) Body file: EGSR
13
14 GOPTIONS ACCESSIBLE;
ERROR: Invalid macro name (. It should be a valid SAS identifier no longer than 32 characters.
ERROR: A dummy macro will be compiled.
15 %macro export(libname, numvars= &numvars.);
16 %do i= 1 %to &numvars.;
17 proc export data=&libname.StateZip&i
18 DBMS=CSV REPLACE
19 outfile= '&libname.StateZip&i.csv';
20 run;
21 %end;
22 %mend;
23
24 %export(g, numvars= 51);
24 +(libname, numvars= &numvars.);
_
10
ERROR 10-205: Expecting the name of the procedure to be executed.
24 +(libname, numvars= &numvars.);
_
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
2 The SAS System 11:38 Wednesday, September 5, 2012
180: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL may allow recovery of the LINE and COLUMN where the
error has occurred.
您可以提供的任何帮助将不胜感激。