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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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