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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 1491 views
  • 1 like
  • 2 in conversation