gpt4 book ai didi

SAS 数组创建

转载 作者:行者123 更新时间:2023-12-01 23:16:11 25 4
gpt4 key购买 nike

我正在尝试创建包含一个值的数组。

proc sql noprint;
select count(*) into :dscnt from study;
select libname into :libname1 - :libname&dscnt from study;
quit;

我认为语法是正确的,但我在 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.***

有人可以向我解释我做错了什么吗?

谢谢

最佳答案

您无需提前知道项数,如果将其留空,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;

结果:

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

关于SAS 数组创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50068103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com