University of Rochester Medical Center
SearchDirectoryNewsEventsStrong HealthURMC Home

SAS Helpful Hints

Proc Gplot(+/- Standard Error over Time)

Here is a gplot that looks at data over time by treatment group. I have included many of my favorite graphic options to improve the appearance of the graph. Feel free to modify the options to suite your own personal taste.

Proc Sort Data=work.A; By scale treatment visit; Run;

Proc Means Data=work.A Noprint;
    By scale treatment visit;
    Var value;
    Output Out=work.B Mean=value Stderr=stderr;
Run;

Data work.C;
    Set work.B;
    value=value+stderr; Output;
    value=value-2.0*stderr; Output;
Run;

Title1 Font=Centx Height=2 'Changes over time';

Goptions Device=Win Colors=(Black White Blue Red Gold Green Cyan)
        Display Fby=Centx Hby=2 Cback=White;

Axis1 Width=2 Major=(Width=2) Minor=(Width=2) Value=(Font=Duplex Height=2)
        Label=(Angle=90 Rotate=0 Font=Centx Height=2 'Mean Change +- StdErr');

Axis2 Width=2 Major=(Width=2) Minor=(Width=2) Value=(Font=Duplex Height=2)
        Label=(Font=Centx Height=2 'Visit') Order=0 To 20 By 4;

Legend1 Label=(Font=Centx Height=2) Value=(Font=Centx Height=2)
    Across=4 Down=1 Position=(Outside|Inside Top|Middle|Bottom Left|Center|Right);
Symbol1 Value=None Interpol=Hilotj Line=1 Width=2 Bwidth=2 Color=Blue;
Symbol2 Value=None Interpol=Hilotj Line=1 Width=2 Bwidth=2 Color=Green;
Symbol3 Value=None Interpol=Hilotj Line=1 Width=2 Bwidth=2 Color=Red;
Symbol4 Value=None Interpol=Hilotj Line=1 Width=2 Bwidth=2 Color=Gold;

Proc Gplot Data=work.C Gout=work.plot;
    By scale;
    Plot value*visit=treatment / Frame Vaxis=axis1 Haxis=axis2 Legend=legend1;
Run;

Please send your comments and suggestions about this web page to A. Watts (watts@bst.rochester.edu)