3qsir 发表于 2014-3-9 12:24
I delete All "t1" string , but still error in the code:
------------------------------------------- ...
Sas considered '&yf&mf.'n as a column (variable) name, not the expected '201103'n, '201104'n, ...
Reason: Macro variable reference can not be resolved inside single quotation mark.
Try the following code, instead of creating sql code using macro statements.
- %macro mm(smonth=);
- proc sql noprint;
- select name, count(*) into :mvar separated by ' ', :n
- from dictionary.columns
- where libname='WORK' and memname = 'MONTHLY'
- order by name;
- quit;
- data _null_;
- length keepvar $300 var $10;;
- do i = 1 to &n;
- if "&smonth" = scan("&mvar", i) then start=i;
- end;
- do i = start to start+23;
- var = cats("'", scan("&mvar", i), "'", "n");
- keepvar = catx(' ', keepvar, var);
- end;
- call symput('keepvar', keepvar);
- run;
- data H&smonth;
- set monthly;
- keep ind &keepvar;
- run;
- %mend mm;
- %mm(smonth=201103);


雷达卡
京公网安备 11010802022788号







