Reputation: 15
Hi I am trying to call a macro for each row in the data set using the code below
proc sql;
select cats('%run_procreg(name=',name,',month=',month,')') into :macrocalllist
separated by ' ' from dataset_a;
quit;
¯ocalllist;
I am getting the 'variable maximum length' error:
SAS length of the value of the macro variable MACROCALLLIST (65540) exceeds the maximum length (65534). The value has been
truncated to 65534 characters.
because of the number of rows in the data set. Could you suggest a work-around?
Thank you,
Upvotes: 1
Views: 3019
Reputation: 6378
CALL EXECUTE is one option. It allows you to generate a series of macro calls using data from a dataset, without storing the macro invocations in a macro variable.
For example:
%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
;
And the log will show:
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.
Upvotes: 0