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

I've just began teaching myself plot procedures and very basic macros (ie %LET Statements).  I've written a program with the purpose of producing multiple plots in one PDF.  The program will be run annually.  Reading the support pages I've been able to get pieces of what I want, but I can't seem to get it all together.  So far the closest I've gotten is this:

ods listing close;

ods pdf file='O:\HIV Core Statistics Products\HIV Surveillance\Results\2014\plots\LHD_HTR.pdf';

proc gplot data = _LHD_HTR;

    plot HTR*year=lhd;

    symbol pointlabel=("#HTR") interpol=join value = dot;title 'LHD: HTR';

run;quit;

ods pdf close;

ods listing;

It produces a PDF of my plot where I want it, but there are 2 issues:

     1) I don't know how to make my next plot appear on the 2nd page of the PDF and not overwrite this one.

     2) I'd like the "2014" in the 'ods pdf file= path' to be automatically updated each year.  I created a "%let this_yr = 2014" statement, but the file=path does not understand '&this_yr' or libnames.

Thanks for any help.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

1. Place GPLOT code after first set of code, within the ODS PDF Statement

2. Use double quotes in the file= statement and the macro variable will resolve.

%let yr=2014;

ods listing close;

ods pdf file="O:\HIV Core Statistics Products\HIV Surveillance\Results\&yr.\plots\LHD_HTR.pdf";

title 'First Plot';

proc gplot data = _LHD_HTR;

    plot HTR*year=lhd;

    symbol pointlabel=("#HTR") interpol=join value = dot;title 'LHD: HTR';

run;quit;

title 'Second Plot';

proc gplot data=_LHD_HTR;

   plot HTR*year=lhd;

    symbol pointlabel=("#HTR") interpol=join value = dot;title 'LHD: HTR';

run;quit;

ods pdf close;

ods listing;

View solution in original post

1 REPLY 1
Reeza
Super User

1. Place GPLOT code after first set of code, within the ODS PDF Statement

2. Use double quotes in the file= statement and the macro variable will resolve.

%let yr=2014;

ods listing close;

ods pdf file="O:\HIV Core Statistics Products\HIV Surveillance\Results\&yr.\plots\LHD_HTR.pdf";

title 'First Plot';

proc gplot data = _LHD_HTR;

    plot HTR*year=lhd;

    symbol pointlabel=("#HTR") interpol=join value = dot;title 'LHD: HTR';

run;quit;

title 'Second Plot';

proc gplot data=_LHD_HTR;

   plot HTR*year=lhd;

    symbol pointlabel=("#HTR") interpol=join value = dot;title 'LHD: HTR';

run;quit;

ods pdf close;

ods listing;

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
  • 1 reply
  • 954 views
  • 1 like
  • 2 in conversation