data al;
input a;
cards;
11
12
13
14
15
16
17
18
19
20
21
22
23
run;
data _null_;
set al;
call symputx("n"||put(_N_,1.),a);
run;
1) can someone try it by above code to resolve macro variable and errors?
2) I think it error becoz of in function length.
3) Please try it only in using above code and got it using SQL...
ERROR: Symbolic variable name N* must contain only letters, digits, and underscores.
NOTE: Argument 1 to function SYMPUTX('n*',20) at line 310 column 6 is invalid.
a=20 _ERROR_=1 _N_=10
ERROR: Symbolic variable name N* must contain only letters, digits, and underscores.
NOTE: Argument 1 to function SYMPUTX('n*',21) at line 310 column 6 is invalid.
a=21 _ERROR_=1 _N_=11
Format 1. cannot accomodate numbers > 9. Try:
data _null_;
set al;
call symputx(cats("n", _N_), a);
run;
Format 1. cannot accomodate numbers > 9. Try:
data _null_;
set al;
call symputx(cats("n", _N_), a);
run;
Aside from the format error, it is usually not necessary to keep numbered lists of macro variables, as code can be created right off the dataset with call execute().
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.