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

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,

1 ACCEPTED SOLUTION

Accepted Solutions
ErikLund_Jensen
Rhodochrosite | Level 12

Hi @Jack_Sabbath 

 

Just an idea - try to change single quotes around title to double quotes, because the macro variable won't resolve within single quotes.

View solution in original post

3 REPLIES 3
ErikLund_Jensen
Rhodochrosite | Level 12

Hi @Jack_Sabbath 

 

Just an idea - try to change single quotes around title to double quotes, because the macro variable won't resolve within single quotes.

Tom
Super User Tom
Super User

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.

PaigeMiller
Diamond | Level 26

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; 

 

--
Paige Miller

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 9231 views
  • 6 likes
  • 4 in conversation