【问题标题】:SAS length of the value of the macro variable exceeds the maximum length宏变量值的SAS长度超过最大长度
【发布时间】:2016-05-02 20:21:11
【问题描述】:

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

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


&macrocalllist;

我收到“可变最大长度”错误:

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

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

谢谢,

【问题讨论】:

  • 你的数据集中有多少行?

标签: macros sas


【解决方案1】:

调用执行是一种选择。它允许您使用数据集中的数据生成一系列宏调用,而无需将宏调用存储在宏变量中。

例如:

%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.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-10
    • 2017-11-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-06
    • 2016-07-17
    • 1970-01-01
    • 2016-03-09
    相关资源
    最近更新 更多