DATA Step, Macro, Functions and more

How to resolve a macro using call symputx?

Accepted Solution Solved
Reply
Contributor
Posts: 52
Accepted Solution

How to resolve a macro using call symputx?


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


Accepted Solutions
Solution
a week ago
Respected Advisor
Posts: 4,927

Re: How to resolve a macro using call symputx?

Posted in reply to rajeshalwayswel

Format 1. cannot accomodate numbers > 9. Try:

 

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

View solution in original post


All Replies
Solution
a week ago
Respected Advisor
Posts: 4,927

Re: How to resolve a macro using call symputx?

Posted in reply to rajeshalwayswel

Format 1. cannot accomodate numbers > 9. Try:

 

data _null_;
set al;
call symputx(cats("n", _N_), a);
run;
PG
Super User
Posts: 7,809

Re: How to resolve a macro using call symputx?

Posted in reply to rajeshalwayswel

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

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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