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

Hi all,

 

I have created a patient report, in which I used proc gplot (to draw a graph), proc sgplot (to draw another graph) and proc print (to print a listing) of one patient of interest through ODS. The graphs and listing came out fine, but are all on individual page, which is not good and efficient for the data cross checking.

 

Question for the community, is it possible to print all the graphs and listing output on one page for one patient? I used a marco to loop through the patient list to get every single patient data printed on one page for effective data review.

 

Thanks  

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
If you've never specified the STARTPAGE option the default is each new PROC outputs to a new page. Your code shows no use of the STARTPAGE option. For starters try setting it to never.

ods pdf file="C:\Users\Documents\plot_&sub..pdf" startpage=NEVER ;

https://support.sas.com/rnd/base/ods/odsprinter/PDF-tips.pdf

View solution in original post

18 REPLIES 18
PaigeMiller
Diamond | Level 26

Which ODS destination are you using?

--
Paige Miller
zimcom
Pyrite | Level 9

%macro loops;
%do i=1 %to &cnt;
data _null_;
set lst;
if _n_ = &i then call symput('sub',subject);
run;
%put ⊂
ods pdf file="C:\Users\Documents\plot_&sub..pdf" ;

goptions reset=all hsize=15cm vsize=10cm;
axis2 order=(0 to 6) minor=none;
symbol1 interpol=join width=2 color=vligb value=dot height=6;
symbol2 interpol=join width=2 color=salmon value=dot height=6;

proc gplot data=data1;
where subject = "&sub";
by SUBJECT;
plot a * b/ overlay vaxis=axis2;
run;

proc sgplot data=ae;
format aestdat date7.;
refline 0 / axis=x lineattrs=(color=black);
highlow y=aeseq low=aestdy high=aeendy / type=bar group=aesev
lineattrs=(color=black pattern=solid) barwidth=0.8
lowlabel=aedecod highcap=highcap attrid=Severity;
scatter y=aeseq x=aestdat / x2axis markerattrs=(size=0);
xaxis grid display=(nolabel) offsetmax=0.02;
x2axis display=(nolabel) offsetmax=0.02 ;
yaxis grid display=(noticks novalues nolabel);
where subject = "&sub";
by SUBJECT;
run;

proc print data=dm;
where subject = "&sub";
run;


ods pdf close;
quit;
%end;
%mend;
%loops;

PaigeMiller
Diamond | Level 26

As stated by @ballardw, there's only so much space on a page, and maybe your output doesn't fit. You can try reducing the margins to squeeze just a little more onto the page, or you can try reducing the size of your graphics and reducing the font size of your PROC PRINT output ... but really, there's only so much you can do before eitehr you are forced to use another page or the graphs and text become so small taht it isn't readable.

--
Paige Miller
zimcom
Pyrite | Level 9
I checked the output, the space is not the reason that pushed the 2nd graph onto the next page, the lisitng is only one row, so all of them should fit into one page if there is such a control.
Thanks
ballardw
Super User

@zimcom wrote:
I checked the output, the space is not the reason that pushed the 2nd graph onto the next page, the lisitng is only one row, so all of them should fit into one page if there is such a control.
Thanks

SAS inserts vertical space between output so you may need to look closer.

But your example code shows nothing attempting to control spacing.  The ODS PDF option STARTPAGE default setting is YES, which places each procedure's output on a separate page. You might try adding

STARTPAGE=NO to force all of the output to single page. But I still suspect you're going to have to play around with the size of the SGPLOT size. Personally I would move the GPLOT code to SGPLOT and then a single setting with ODS Graphics would set a similar height and width on the page.

 

If you are using the BY Subject to get the By line information as a label you might consider actually using Title statements, which you can control font size and the option GTITLE which makes the title part of the graphic output. I suspect that the space between the BY line and the graph may take up more space then you think.

zimcom
Pyrite | Level 9
"the GPLOT code to SGPLOT and then a single setting with ODS Graphics would set a similar height and width on the page." This would be ideal, if I can make the two graphs consistent, but I can't find the equivalent code of SGPLOT to draw what I did by using GPLOT, and I am new to SAS graphics procedure.
DanH_sas
SAS Super FREQ

If you're asking about setting the size on an SG procedure output, use the ODS Graphics statement:

 

odd graphics / width=15cm height=10cm;

 

Think of this statement as similar to the GOPTIONS statement, from the perspective that global options for ODS Graphics can be controlled from this statement.

zimcom
Pyrite | Level 9

That helps to make the graphs the same size and looks much better.

Can proc sgplot draw the same graph as proc gplot did in my case, if this is possible, then all the graph setting can only be set once, that is what I meant. 

DanH_sas
SAS Super FREQ

If you're asking if your GPLOT example can be drawn using SGPLOT, the answer is yes. There code would look something  like the following:

proc sgplot data=data1;
where subject = "&sub";
by SUBJECT;
yaxis values=(0 to 6);
series x=b y=a / markers lineattrs=(color=vligb thickness=2) markerattrs=(symbol=circlefilled size=6);
run;
DanH_sas
SAS Super FREQ

BTW, you do not need to use the BY statement, since you are using a WHERE clause.

zimcom
Pyrite | Level 9
I use the by statement to show the Subject ID on the graph
zimcom
Pyrite | Level 9
Thank you so much for your help! I really appreciated it!!
Reeza
Super User
If you've never specified the STARTPAGE option the default is each new PROC outputs to a new page. Your code shows no use of the STARTPAGE option. For starters try setting it to never.

ods pdf file="C:\Users\Documents\plot_&sub..pdf" startpage=NEVER ;

https://support.sas.com/rnd/base/ods/odsprinter/PDF-tips.pdf
Reeza
Super User
You don't include data but your GPLOT looks like just a basic SERIES plot? Have you tried a SERIES statement in SGPLOT?

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
  • 18 replies
  • 2337 views
  • 4 likes
  • 5 in conversation