宏变量值的SAS长度超过最大长度

时间:2016-05-02 20:21:12

标签: macros sas

您好我正在尝试使用下面的代码为数据集中的每一行调用一个宏

proc sql;
select cats('%run_procreg(name=',name,',month=',month,')') into :macrocalllist
  separated by ' ' from dataset_a;
quit;


&macrocalllist;

我得到的变量最大长度为'错误:

  

宏变量MACROCALLLIST(65540)的值的SAS长度   超过最大长度(65534)。价值已经是   截断为65534个字符。

因为数据集中的行数。你能建议一个解决方法吗?

谢谢,

1 个答案:

答案 0 :(得分:0)

CALL EXECUTE是一个选项。它允许您使用数据集中的数据生成一系列宏调用,而不将宏调用存储在宏变量中。

例如:

%macro testprint(data=,obs=);
  proc print data=&data (obs=&obs);
  run;
%mend testprint;

data _null_;
  input datasetname $13. obs;
  call execute('%nrstr(%testprint(data='||datasetname
                               ||',obs='||put(obs,1.)
                               ||'))'
               );
  cards;
sashelp.shoes 3
sashelp.class 5
;

日志将显示:

NOTE: CALL EXECUTE generated line.
131  ;
1   + %testprint(data=sashelp.shoes,obs=3)    
NOTE: There were 3 observations read from the data set SASHELP.SHOES.   
2   + %testprint(data=sashelp.class,obs=5)    
NOTE: There were 5 observations read from the data set SASHELP.CLASS.
相关问题