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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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