The sample code on the Full Code tab draws a "spaghetti plot" that contains one plot line per patient over multiple visits. The color of the plot line indicates the treatment group. SYMBOL statements are generated dynamically based on the value of the treatment group for each line. A FOOTNOTE statement is defined to simulate a legend for the treatment groups.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
The graphics output in the Results tab was produced using SAS® 9.2. Submitting the sample code with releases of SAS prior to SAS 9.2 might produce different results.
/* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;
/* Create sample data to plot. */
data test;
input treatment visit patient response;
datalines;
1 1 100 20
1 2 100 30
1 3 100 35
1 4 100 50
1 1 200 40
1 2 200 25
1 3 200 45
1 4 200 60
2 1 300 15
2 2 300 40
2 3 300 50
2 4 300 30
2 1 400 60
2 2 400 55
2 3 400 70
2 4 400 35
;
run;
proc sort data=test;
by patient;
run;
/* Create macro variables that resolve to build SYMBOL statements. */
/* A separate SYMBOL statement is generated for each patient within */
/* each treatment group. */
data _null_;
set test end=eof;
retain patcount 0;
by patient;
if first.patient then patcount+1;
if treatment=1 then do;
call symput('sym'||trim(left(patcount)),
'symbol'||trim(left(patcount))
|| ' '|| 'c=black'|| ' '||'v=none'||' '
|| 'i=join'|| ' ' || 'line=1' || 'width=1' ||';');
end;
if treatment=2 then do;
call symput('sym'||trim(left(patcount)),
'symbol'||trim(left(patcount))
|| ' '|| 'c=vibg'|| ' '||'v=none'||' '
|| 'i=join'|| ' ' || 'line=1' || 'width=1' ||';');
end;
if eof then call symput('total',patcount);
run;
/* Create a macro that generates all SYMBOL statements. */
%macro symbol;
%do j=1 %to &total;
&&sym&j
%end;
%mend symbol;
/* Execute the macro to generate the SYMBOL statements. */
%symbol
axis1 label=(a=90 'Response')
order=(0 to 100 by 10);
axis2 label=('Visit') minor=none;
title1 "Response by Patient and Treatment Group";
/* A FOOTNOTE statement is used to simulate a legend. */
footnote1 box=1 lspace=1 'Treatment Group: '
color=black draw=(+3,+0.5,+8,+0)
move=(+11,+0) " 1"
color=vibg draw=(+3,+0.5,+8,+0)
move=(+11,+0) color=black " 2";
/* Generate the graph. */
proc gplot data=test;
plot response*visit=patient / vaxis=axis1 haxis=axis2
nolegend;
run;
quit;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> GPLOT Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Symbols/Interpolation Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Plots ==> Line |
Date Modified: | 2009-12-08 15:29:13 |
Date Created: | 2009-12-08 15:16:02 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/GRAPH | z/OS | 9 TS M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9 TS M0 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9 TS M0 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9 TS M0 | |||
Microsoft Windows 2000 Advanced Server | 9 TS M0 | |||
Microsoft Windows 2000 Datacenter Server | 9 TS M0 | |||
Microsoft Windows 2000 Server | 9 TS M0 | |||
Microsoft Windows 2000 Professional | 9 TS M0 | |||
Microsoft Windows NT Workstation | 9 TS M0 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9 TS M0 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9 TS M0 | |||
Microsoft Windows Server 2003 Standard Edition | 9 TS M0 | |||
Microsoft Windows XP Professional | 9 TS M0 | |||
64-bit Enabled AIX | 9 TS M0 | |||
64-bit Enabled HP-UX | 9 TS M0 | |||
64-bit Enabled Solaris | 9 TS M0 | |||
HP-UX IPF | 9 TS M0 | |||
Linux | 9 TS M0 | |||
OpenVMS Alpha | 9 TS M0 | |||
Tru64 UNIX | 9 TS M0 |