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

Dear Everyone,
I wanted to add prefix "o" to all the variables in foo.
But I don't understand what is missing. 
Can anyone point me out please?
Thanks in advance.
After the last iteration, this is what SAS log shows.

SYMBOLGEN:  Macro variable VAR86 resolves to val86
MLOGIC(ADDPREFIX):  %DO loop index variable I is now 87; loop will not iterate again.
NOTE: Line generated by the invoked macro "ADDPREFIX".
10937    quit; run;
             -
             73
             76

The error it gives are
ERROR 73-322: Expecting an =.

ERROR 76-322: Syntax error, statement will be ignored.

 

%macro addprefix(add=);
proc datasets library=work;
modify foo;
rename %do i=1 %to &num_vars.; &&var&i=&add.&&var&i. %end;
quit;
run;
%mend addprefix;
%addprefix(add=o);

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
gamotte
Rhodochrosite | Level 12
Hello,

I think you miss a semi-colon for the rename statement (after %end;).

View solution in original post

3 REPLIES 3
gamotte
Rhodochrosite | Level 12
Hello,

I think you miss a semi-colon for the rename statement (after %end;).
Miracle
Barite | Level 11

Thanks @gamotte for your quick response.

Why is another ; needed?

gamotte
Rhodochrosite | Level 12
You're welcome.
One ';' for the %end (i.e. for the macro instruction %do; ... %end;) and another for the rename statement.
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
  • 3 replies
  • 2125 views
  • 1 like
  • 2 in conversation