BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.


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

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Format 1. cannot accomodate numbers > 9. Try:

 

data _null_;
set al;
call symputx(cats("n", _N_), a);
run;
PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Format 1. cannot accomodate numbers > 9. Try:

 

data _null_;
set al;
call symputx(cats("n", _N_), a);
run;
PG
Kurt_Bremser
Super User

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().

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1662 views
  • 3 likes
  • 3 in conversation