Hi, i have a problem with the dimension definiton of an array. My code works good in SAS Guide, but in the bash does't works.
The macro variables nvars and obs are definited as:
data _null_;
set sashelp.vtable (where= (memname='ABT_DUMMY'));
call symput('nvars', nvar-1);
call symput('obs', nobs);
run;
I wish to put the macros in array dimension:
data bt_lambda (keep= var dot);
array xx[&nvars.] x_1-x_&nvars.;
array xd[&obs., &nvars.] _temporary_;
run;
But return the errors:
The code works if i defined the macros as:
%let nvars=23;
%let obs=84000;
But i need the dynamical dimension. Someone can tell me a solution?
The log shows that "nvars" is -1 not 23. Using call symputx is recommended, so that blanks are automatically stripped from the macro-variable.
The log shows that "nvars" is -1 not 23. Using call symputx is recommended, so that blanks are automatically stripped from the macro-variable.
First of all, use CALL SYMPUTX instead of CALL SYMPUT. SYMPUTX strips leading and trailing blanks.
It looks as if your dataset does not contain any variables (resulting in nvars being -1, which is an invalid dimension for the array).
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.