Below is the code, not sure whats the issue the proc gplot output is showing twice.
Also, another question - how to suppress the directory and dataset contents table in the output pdf file.
*raw data path;
libname seretide "C:/xxxx" INENCODING=ASCIIANY;
*transformed data path;
libname strans "C:/xxxx" INENCODING=ASCIIANY;
proc datasets library=work nodetails kill;
/* modify have/ correctencoding='utf8'; */
quit;
ods listing close;
ods pdf file="C:\Users\User\0001.pdf" startpage=no;
proc sort data=seretide.en out=entable
(drop = subjectstatus visit form formentrydate subjectvisitformid);
by subjectid;
run;
proc sort data = seretide.dm out=dmtable
(drop = subjectstatus visit form formentrydate subjectvisitformid);
by subjectid;
run;
proc sort data=seretide.cm out = cmtable
(drop = subjectstatus visit form formentrydate subjectvisitformid);
by subjectid;
run;
proc sql noprint;
create table work.en_dm_cm as
select entable.*, dmtable.*, cmtable.*
from work.entable (where = (subjectid = '0001'))
left join work.dmtable (where = (subjectid = '0001'))
on entable.subjectid = dmtable.subjectid
left join work.cmtable (where = (subjectid = '0001'))
on entable.subjectid = dmtable.subjectid;
quit;
data patdemo;
set en_dm_cm;
where subjectid = '0001';
label SCRID = 'Screening Number'
SUBJINIT = 'Subject Initials'
BRTHDTC = 'Date of Birth'
AGE = 'Age (In Years)'
RACE = 'Race';
if _n_ = 1;
run;
proc print data=patdemo noobs label;
Variables SCRID SUBJINIT SUBJID BRTHDTC AGE SEX ETHNIC RACE;
Title 'Patient Information for 0001';
run;
proc sort data=seretide.ae out=aetable;
by subjectid;
run;
data aetab (Keep= SUBJECTID AEYN AESEV AESTDAT AEENDAT AEACN AEOUT);
set work.aetable;
where subjectid = "0001";
Label AEYN = 'Adverse Event Yes/No'
AESEV = 'Adverse Event Severity'
AESTDAT = 'Adverse Event Start Date'
AEENDAT = 'Adverse Event End Date'
AEACN = 'Action Taken'
AEOUT = 'Outcome';
run;
Proc print data=aetab noobs label;
Title "No Adverse Events Reported for Patient ID: 0001";
run;
data cmtab;
set work.en_dm_cm
(keep = subjectid CMYN CMTRT CMTRT_PREFERRED CMTRT_DRUGNAME
CMINDC CMSTDAT CMENDAT CMDOSTXT CMDOSU CMDOSUSP CMDOSFRQ
CMFREQSP CMROUTE CMROUTSP );
where subjectid = '0001' and CMYN eq ' ';
select;
when (CMDOSU = 'Other') CMDOSU = '(mcg)';
when (CMDOSU = 'Milligram') CMDOSU = '(Mg)';
when (CMDOSU = 'Puff') CMDOSU = '(pf)';
Otherwise CMDOSU = '(IU)';
end;
if CMDOSFRQ = 'Other' then CMDOSFRQ = CMFREQSP;
if CMDOSFRQ ne ' ' then
DDWF = Strip(CMTRT) || ' ' || strip(CMDOSTXT) || ' ' || strip(CMDOSU) || ' ' || '(' || strip(CMDOSFRQ) || ')';
else DDWF = Strip(CMTRT) || ' ' || strip(CMDOSTXT) || strip(CMDOSU);
Label DDWF = 'Drug Dosage with Frequency';
Drop SUBJECTID CMYN CMTRT CMTRT_PREFERRED CMTRT_DRUGNAME CMDOSTXT CMDOSU
CMDOSUSP CMDOSFRQ CMFREQSP CMROUTSP;
run;
proc print data=cmtab noobs label;
Title 'Concomitant Medication history for Patient ID 0001';
run;
proc sort data=seretide.vs out=vstable;
by subjectid;
run;
data vstab;
set vstable (keep = SUBJECTID VISIT VSPERF VSDAT VSPOS VSTEST VSORRES
VSORRESU VSTEST1 VSORRES1 VSORRESU1);
where subjectid = '0001';
select;
when (VSORRESU = 'CM') VSORRESU = '(cm)';
when (VSORRESU = 'Kg') VSORRESU = '(kg)';
when (VSORRESU = 'Degree Fahrenheit') VSORRESU = '(°F)';
when (VSORRESU = 'Beats per Minute') VSORRESU = '(bpm)';
when (VSORRESU = 'Breaths per Minute') VSORRESU = '(brpm)';
when (VSORRESU = 'mm Hg') VSORRESU = '(mm Hg)';
when (VSTEST = 'Height') VSORRESU = '(cm)';
otherwise VSORRESU = ' ';
end;
select;
when (VSORRESU1 = 'CM') VSORRESU1 = '(cm)';
when (VSORRESU1 = 'Kg') VSORRESU1 = '(kg)';
when (VSORRESU1 = 'Degree Fahrenheit') VSORRESU1 = '(°F)';
when (VSORRESU1 = 'Beats per Minute') VSORRESU1 = '(bpm)';
when (VSORRESU1 = 'Breaths per Minute') VSORRESU1 = '(brpm)';
when (VSORRESU1 = 'mm Hg') VSORRESU1 = '(mm Hg)';
otherwise VSORRESU1 = ' ';
end;
if Visit = ('Randomization (Visit 2/Day 0)') or
Visit = ('End of Treatment/Early termination (Visit 3)') then do;
VSTEST = VSTEST1;
VSORRES = VSORRES1;
VSORRESU = VSORRESU1;
end;
retain _vsdat _vspos;
if not missing(vsdat) then _vsdat = vsdat;
else vsdat = _vsdat;
if not missing(vspos) then _vspos = vspos;
else vspos = _vspos;
if vsperf = 'Yes' then delete;
drop _vsdat _vspos VSPERF VSTEST1 VSORRES1 VSORRESU1 ;
run;
Proc sort data=vstab (where=(vstest ne 'Height')) out=vstab;
by vstest vsdat;
run;
data vsdia vssys vstemp vswt vshr vsresp;
set vstab;
if vstest = 'Diastolic Blood Pressure' then output vsdia;
if vstest = 'Systolic Blood Pressure' then output vssys;
if vstest = 'Temperature' then output vstemp;
if vstest = 'Weight' then output vswt;
if vstest = 'Heart Rate' then output vsresp;
run;
Title 'Vital Stats Diastolic Blood Pressure for Patient ID: 0001';
PROC GPLOT DATA = vsdia;
SYMBOL1 INTERPOL=JOIN HEIGHT=10pt VALUE=NONE LINE=1 WIDTH=2 CV = _STYLE_;
Axis1 STYLE=1 WIDTH=1 MINOR=NONE label = ('(Hg mm)');
Axis2 STYLE=1 WIDTH=1 MINOR=NONE;
PLOT VSORRES * VSDAT /
VAXIS=AXIS1
HAXIS=AXIS2
FRAME;
BY VSTEST;
RUN;
ods pdf close;
ods listing;
Running this in EG? Or SAS Studio?
Add QUIT; after the RUN; in the PROC GPLOT block.
RUN; is required to run it. Another RUN; before a QUIT will run it again... And EG/SAS Studio automatically add a RUN/QUIT 1-2 punch to close out open-ended statements.
BY VSTEST;
This will likely cause the multiple plots. Are you sure they're identical?
Some suggestions:
Removed the by statement as it is not relevant now.
But still graph is getting duplicated.
Also, where exactly you mean to move the ods pdf line as per the given code above?
Right before the output starts, so in this case it's before PROC GPLOT.
But I need output from first proc print as below:
proc print data=patdemo noobs label;
Can you move the PROC PRINT?
EDIT: This is a style issue, you don't need to make the change. I just find it easier to have my code set up in this manner.
snoopy,
Reg. directory and datasets: I meant in the result window 2 tables are displayed on top as attached. I don't want that in the output PDF.
Krisraa, that is indeed the PROC DATASETS output.
What that means to me is that you are somehow running this twice without closing ODS PDF. I.e., something like this is actually happening:
proc datasets ... ;
quit;
ods pdf file="whatever.pdf";
proc gplot ... ;
run;
...
proc datasets ...;
quit;
ods pdf file="whatever.pdf";
proc gplot ... ;
run;
ods pdf close;
I'm sure that's not what you intended. The ODS PDF CLOSE; is not happening after the first run, for whatever reason.
Running this in EG? Or SAS Studio?
Add QUIT; after the RUN; in the PROC GPLOT block.
RUN; is required to run it. Another RUN; before a QUIT will run it again... And EG/SAS Studio automatically add a RUN/QUIT 1-2 punch to close out open-ended statements.
Chris,
Thanks! yes adding quit; resolved it.
Using SAS Studio 3.5
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 25. 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.