SAS PROGRAMMING HANDOUT #28 This handout will illustrate some of the features of PROC GPLOT. LIBNAME JIM 'A:\STAT534'; DATA GNP; SET JIM.GNP; IF RANUNI(0)<.5 THEN GROUP='A'; ELSE GROUP='B'; IF GROUP='A' THEN GNP=10000-GNP; PROC MEANS; RUN; *GOPTIONS DEVICE= WIN or WINPRTM; PROC GPLOT; TITLE1 F=SWISSB H=1 'GROSS NATIONAL PRODUCT'; TITLE2 F=SWISSB H=1 'VERSUS YEAR'; PLOT GNP*DATE=GROUP / HAXIS=AXIS1 VAXIS=AXIS2 ; SYMBOL1 V=A H=1 I=JOIN L=1 C=RED; SYMBOL2 V=B H=1 I=JOIN L=2 C=BLACK; AXIS1 LABEL=( H=1 F=SWISSB 'DESCRIBE X VARIABLE HERE' ) W=3 VALUE=(F=SWISSB); AXIS2 LABEL=( H=1 F=SWISSB ANGLE=90 ROTATE=0 'DESCRIBE Y VARIABLE HERE') W=3 VALUE=(F=SWISSB); FOOTNOTE J=L H=1 'DONE BY JIM'; NOTE F=SWISS H=.75 MOVE=(5PCT,50PCT) 'THIS IS 5-50'; NOTE F=ITALIC H=.5 MOVE=(90PCT,80PCT) 'THIS IS 90-80'; NOTE F=SWISS H=2.0 MOVE=(50PCT,50PCT) 'MIDDLE'; RUN; TITLE1; TITLE2; FOOTNOTE; PROC GPLOT; PLOT (INVEST GOVT)*DATE/OVERLAY; SYMBOL1 V=DOT H=1 I=RL L=1 C=RED; SYMBOL2 V=STAR H=1 I=RQ L=2 C=BLACK; RUN; The GOPTIONS DEVICE statement tells SAS where to print the plot (on screen or directly to the printer. The plot will look different if you first view it on the screen and then print it off. Usually you would send it to the screen until you perfected it. Then finally print a hard copy using either the print icon or the device statement. Here the TITLE statements put titles on the graph. F = various fonts, ITALIC, SWISS, GREEK, MATH, GERMAN, MUSIC,.... H = height of the characters Here the SYMBOL command refers to the different levels of the GENDER variable. V= PLUS, STAR, letters, etc, try $,",-,%... H= height of symbol I= JOIN (joins points), STEPL, STEPR (draws step functions), STD2 (draws vertical mean +- 2 std), HILO (draws veritcal high/low) RL, RQ, RC (draws linear, quadratic or cubic regressions) RLCLM95 etc (draws 95% confidence intervals for regression means value) RLCIM90 etc (draws 90% confidence intervals for regression individual value) L= 1 to 32 (various dashed lines) C= various colors Here the AXIS statements refer to what to put on the axes. Here the NOTE statmenets put various notes on the graph MOVE = can be stated in terms on PCT (percent) or IN (inches) There are several things you can do with your graph: 1) Print it (DEVICE=WINPRTM) 2) Save it. You can save it as a SAS graph using GOUT or/ You can (FILE-->EXPORT AS IMAGE) save it as a *.JPG file, or *.BMP file *.JPG files take up much less space!!!!!! The graph can then be imported to WORD using INSERT -> PICTURE The next program shows how to do PROC GPLOT with a BY statement and have the BY variable appear in the title. TITLE1; TITLE2 TITLE3; FOOTNOTE; OPTIONS NOBYLINE; GOPTIONS HTEST=2; DATA CA88AIR; INFILE 'A:\CA88AIR.TXT'; *this is data set 1 on the web page; INPUT O3 CO NO3 SO4 TEMP HUMID DATE STATION $ MONTH; PROC SORT; BY STATION; PROC GPLOT DATA=CA88AIR NOCACHE; BY STATION; PLOT O3 * MONTH; SYMBOL1 V=DOT I=JOIN L=1; TITLE1 H=2 F=SIMPLEX '1988 Air Quality Data - Ozone'; TITLE2 h=2 F=SIMPLEX 'Plots separated by #byvar1'; TITLE3 h=2 F=SIMPLEX 'OZONE levels at #byval(station)'; FOOTNOTE1 J=l H=2 F=SIMPLEX 'Figure 3.2.6'; run;