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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.