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

Hello all,

I am trying to loop through a macro function which produces multiple plots/tables (via proc sgplot & proc tabulate) for different variables - a different variable is plotted in each call of the macro. The very last plot within the macro is as follows:

proc tabulate data=wr.exante_shock_scenarios;

  title "&Prodcat Shock Scenario Yield Rate Forecasts";

  class 'date'n;

  var Flat_Rate Shock_Up_100_Rate Shock_Up_200_Rate Shock_Down_100_Rate Gradual_Up_100_Rate Gradual_Up_200_Rate Gradual_Down_100_Rate;

  table mean=''*( Flat_Rate="&Prodcat. Flat_Rate"

  Shock_Up_100_Rate="&Prodcat. Shock_Up_100_Rate"

  Shock_Up_200_Rate="&Prodcat. Shock_Up_200_Rate"

  Shock_Down_100_Rate="&Prodcat. Shock_Down_100_Rate"

  Gradual_Up_100_Rate="&Prodcat. Gradual_Up_100_Rate"

  Gradual_Up_200_Rate="&Prodcat. Gradual_Up_200_Rate"

  Gradual_Down_100_Rate="&Prodcat. Gradual_Down_100_Rate")

  *(format=comma20.2),date;

  where prodcat="&Prodcat" and date in ('31DEC2012'd,'31DEC2013'd,'31DEC2014'd,'31DEC2015'd);

  run;

This issue is - the text in that 'title' statement gets output above every subsequent table/produced, which is very misleading because now each of my output plots has a title above - specifying that it is a plot for the previous variable - not the actual current variable being plotted.

I.E. My first two calls to the macro producing the output are as follows:

%Produce_Output(BUSMMSADV);

%Produce_Output(RETNOW);

So now for all of the output plots/tables (the macro contains 4 sgplot statements, and 2 proc tabulates), for the call with parameter 'RETNOW' will contain the text "BUSMMSADV Shock Scenario Yield Rate Forecasts" - which is incorrect, and the call with 'BUSMMSADV' as the parameter will contain that line of text, except listing the &prodcat variable that was passed in on the last time that I executed the macro.

Is there anyway that I can clear this "item title" output so that it is only present in the proc tabulate statement that it was declared within?

Please let me know if I am not explaining this well enough, I tried my best but I feel that I may be somewhat unclear.

Thanks a lot guys!!

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  First rule of Titles and Footnotes: they are global. They stay in effect until changed or deleted. To delete a TITLE or FOOTNOTE,

  I am something of a control freak. I put a TITLE statement for every procedure step I have. But then, I also RESET or DELETE that title statement after the RUN; I know, it seems silly to do that, because if the next procedure has a TITLE statement, that is what will be used. But if I do not RESET the TITLE statement after my -last- procedure, then that TITLE statement will hang around and impact subsequent steps.

 

  So, here's my model. No matter what. All the time, every time. What is within the procedure step belongs to the procedure step. After the procedure, I clear the title and footnote used for the procedure. All the time.

cynthia

proc whatever data=mydata;

  title 'Whatever';

  footnote 'Whatever Else';

  something;

  something;

  something else;

run;

title;

footnote;

 

proc wombat data=moredata;

  title 'Whatever Again';

  footnote; /* no footnote for this step */

  something;

  something;

run;

title;

footnote;

View solution in original post

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

Hi:

  First rule of Titles and Footnotes: they are global. They stay in effect until changed or deleted. To delete a TITLE or FOOTNOTE,

  I am something of a control freak. I put a TITLE statement for every procedure step I have. But then, I also RESET or DELETE that title statement after the RUN; I know, it seems silly to do that, because if the next procedure has a TITLE statement, that is what will be used. But if I do not RESET the TITLE statement after my -last- procedure, then that TITLE statement will hang around and impact subsequent steps.

 

  So, here's my model. No matter what. All the time, every time. What is within the procedure step belongs to the procedure step. After the procedure, I clear the title and footnote used for the procedure. All the time.

cynthia

proc whatever data=mydata;

  title 'Whatever';

  footnote 'Whatever Else';

  something;

  something;

  something else;

run;

title;

footnote;

 

proc wombat data=moredata;

  title 'Whatever Again';

  footnote; /* no footnote for this step */

  something;

  something;

run;

title;

footnote;

AllSoEasy
Obsidian | Level 7

Ahhh I see. I was trying different ODS options, I didn't think it would be as simple as just "title;" Thank you very much Cynthia!!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 5340 views
  • 0 likes
  • 2 in conversation