Hello:
I have the following macro program. However, I got error message in Log. Please help. Thank you.
%let site1=PA;
%let site2=GA;
%let site3=OH;
%macro format;
%do i=1 %to 3;
data RR_&&site&i._format;
set RR_&&site&i;
format caseid $9.
County $50.
consent $3.;
run;
%end;
%mend;
%format;
The error message was shown below.
MPRINT(FORMAT): ods rtf close;
SYMBOLGEN: && resolves to &.
SYMBOLGEN: Macro variable I resolves to 1
WARNING: Apparent symbolic reference SITE not resolved.
NOTE: Line generated by the macro variable "I".
1 RR_&site.1
-
22
200
MPRINT(FORMAT): data RR_&site.1_format;
SYMBOLGEN: && resolves to &.
SYMBOLGEN: Macro variable I resolves to 1
SYMBOLGEN: Macro variable SITE1 resolves to PA
MPRINT(FORMAT): set RR_;
MPRINT(FORMAT): format caseid $9. County $50. consent $3.;
MPRINT(FORMAT): run;
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;,
_DATA_, _LAST_, _NULL_.
ERROR 200-322: The symbol is not recognized and will be ignored.
Hi
can you try this by keeping 2 dots after i instead of 1 dot
RR_&&site&i.._format;
Hi
can you try this by keeping 2 dots after i instead of 1 dot
RR_&&site&i.._format;
Thanks, it works.
If the purpose of this exercise is to add or change the formats for variables in a data set you might look at proc datasets instead. Changing formats is one of the things that procedure is designed for.
Thank you, Ballardw. That was great suggestion.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.
Ready to level-up your skills? Choose your own adventure.