Frequency Plot - SAS Code

advertisement
/***************************************************************************
* Program/Macro:
Figure6
* Lang/Vers:
SAS V9.2
* Author:
Robert Gordon
* Date:
12/28/2011
* Program Title:
Figure26_FreqPlotChangeBaseline
* Description: Used CTSPedia CDISC laboratory data. This program creates a
* frequency plot comparing the change from baseline in ALT between active and
* placebo treatment.
*
* Edit Log: 28Dec2011 - First version complete
****************************************************************************/
/* Using the import function within SAS, pulled in the CSV Wiki Lab dataset
(ADLBC)*/
PROC IMPORT OUT= WORK.adlbc
DATAFILE= "Location.Filename"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;
/* Using the lab dataset, keep only ALT, lab result, change from baseline,
treatment.
*
Combined all active treatments into a single active group. */
data lfts;
set adlbc;
if lbtestcd in ('ALT');
keep usubjid lbtestcd lbstresn chstresn lbstnrhi trtpn treat visit
visitnum;
if trtpn=0 then treat='Drug B';
else treat='Drug A';
if visit ne 'UNSCHEDULED';
if visit ne 'LAB BASELINE';
label treat = 'Treatment';
run;
proc sort data=lfts;
by treat visitnum;
run;
proc freq data=lfts order=data;
table chstresn*visit/cl out=freq;
by treat;
run;
/*Set macro variable for maximum y-axis value to be maximum change from
baseline*/
proc means data=freq;
var count;
*by visitnum;
output out=maxfreq max=maxfreq;
run;
data maxfreq;
set maxfreq;
maxfreq=maxfreq;
call symput('maxfreq',maxfreq);
run;
proc freq data=lfts;
table visit;
run;
data lfts;
set lfts;
visit2=visitnum || visit;
Week= input(substr(visit,6,2),2.);
run;
/* Graph the data using html as the output destination */
goptions reset=all;
ods listing close;
ods html file='FreqPlot.html' path='.' style=statistical ;
ods graphics / reset width=800px height=600px imagename='FreqPlot'
imagefmt=gif ;
title "Frequency Plot of the Change from Baseline in Alanine Aminotransferase
by Visit";
footnote1 ' ';
proc sgpanel data=lfts;
panelby week/spacing=5 onepanel;
vline chstresn/group=treat markerattrs=(size=5)
lineattrs=(thickness=1.5);
colaxis type=linear values=(-20 to 20 by 5) label='Change from Baseline
(U/L)';
rowaxis min=0 max=&maxfreq label='Frequency';
refline 0/axis=x lineattrs=(pattern=solid color=black thickness=.5)
transparency=.5;
refline -20 -10 10 20/axis=x lineattrs=(pattern=solid color=ltgray
thickness=0.1) transparency=.5;
run;
ods html close;
Download