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
Which ODS destination are you using?
%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;
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.
@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.
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.
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.
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;
BTW, you do not need to use the BY statement, since you are using a WHERE clause.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: