Hi,
I trying to include the label from a do loop in a title, though the macro is not displayed in the title. Does anyone have any suggestions as to how to rectify this issue. This is an example of my code:
%macro histogram_plot(sample_data=,vars=, year_l=,year_u=);
%do y = &year_l. %to &year_u.;
proc univariate data=&sample_data. noprint;
title 'Amount Funded &y';
histogram &vars. / normal(mu=est sigma=est color=red w=2.5);
run;
title;
%end;
%mend;
Thank you,
Just an idea - try to change single quotes around title to double quotes, because the macro variable won't resolve within single quotes.
Just an idea - try to change single quotes around title to double quotes, because the macro variable won't resolve within single quotes.
The macro processor ignores values inside of quoted strings using single quote characters on the outside. Just switch to using double quote character to enclose your string instead.
title "Amount Funded &y";
I think there are other issues with the code you posted, but that should fix the TITLE issue.
Forget macros and loops in this case.
proc univariate data=have;
by year;
title "Amount Funded #byval1";
/* Your variable names go on the next line, I used x1 x2 x4 because I don't know your variable names */
histogram x1 x2 x4/ normal(mu=est sigma=est color=red w=2.5);
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.