tit*_*ita 3 sas proc-sql sas-macro
我正在尝试创建包含值的数组。
proc sql noprint;
select count(*) into :dscnt from study;
select libname into :libname1 - :libname&dscnt from study;
quit;
Run Code Online (Sandbox Code Playgroud)
我认为语法是正确的,但我在 SAS Studio 中不断收到以下错误消息。
***NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
NOTE: Line generated by the macro variable "DSCNT".
79 libname 4
_
22
200
ERROR 22-322: Syntax error, expecting one of the following: ',', FROM, NOTRIM.
ERROR 200-322: The symbol is not recognized and will be ignored.***
Run Code Online (Sandbox Code Playgroud)
有人可以向我解释我做错了什么吗?
谢谢
您不需要提前知道项目的数量,如果您将其留空,SAS 将自动创建正确数量的宏变量。
如果您确实想在其他地方使用该号码,您可以使用 TRIMMED 选项创建它以删除任何额外的空格。请参阅下面的第二个示例。
proc sql noprint;
select name into :name1- from sashelp.class;
quit;
%put &name1;
%put &name19.;
proc sql noprint;
select count(distinct name) into :name_count TRIMMED from sashelp.class;
quit;
%put &name_count;
Run Code Online (Sandbox Code Playgroud)
结果:
3068 proc sql noprint;
3069 select name into :name1- from sashelp.class;
3070 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
3071
3072 %put &name1;
Alfred
3073 %put &name19.;
William
3074
3075 proc sql noprint;
3076 select count(distinct name) into :name_count TRIMMED from
3076! sashelp.class;
3077 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
3078
3079 %put &name_count;
19
Run Code Online (Sandbox Code Playgroud)