data dsname; /* GKCL - initial state of DSGI; can execute: */ /* 1. GSET functions that set attributes */ /* that affect the entire graphics output */ /* 2. some catalog management functions */ /* (some GRAPH functions) */ /* Step 1 - initialize DSGI */ rc=ginit(); /* WSAC - workstation is active; can execute: */ /* 1. most GASK routines */ /* 2. some catalog management functions */ /* (some GRAPH functions) */ /* 3. GSET functions that set attributes */ /* and bundles, viewports, windows, */ /* transformations, and message logging */ /* Step 2 - open a graphics segment */ rc=graph("clear", "text"); /* SGOP - segment open; can execute: */ /* 1. any GASK routine */ /* 2. any GDRAW function */ /* 3. some catalog management functions */ /* (some GRAPH functions) */ /* 4. GSET functions that set attributes */ /* and bundles, viewports, windows, */ /* transformations, and message logging */ /* Step 3 - execute graphics primitives */ rc = gdraw("line", 2, 30,50,50,50); /* Step 4 - close the graphics segment */ rc=graph("update"); /* WSAC - workstation is active; can execute: */ /* 1. most GASK routines */ /* 2. some catalog management functions */ /* (some GRAPH functions) */ /* 3. GSET functions that set attributes */ /* and bundles, viewports, windows, */ /* transformations, and message logging */ /* Step 5 - end DSGI */ rc=gterm(); /* GKCL - initial state of DSGI */ run;
/* set the graphics environment */ goptions reset=global gunit=pct border hsize=7 in vsize=5 in targetdevice=pscolor; /* execute a DATA step with DSGI */ data dsname; /* initializesoftware */ /* to accept DSGI statements */ rc=ginit(); rc=graph("clear"); /* assign colors to color index */ rc=gset("colrep", 1, "blue"); rc=gset("colrep", 2, "red"); /* define and display titles */ rc=gset("texcolor", 1); rc=gset("texfont", "swissb"); rc=gset("texheight", 6); rc=gdraw("text", 45, 93, "Simple Graphics Output"); /* change the height and */ /* display second title */ rc=gset("texheight", 4); rc=gdraw("text", 58, 85, "Created with DSGI"); /* define and display footnotes */ /* using same text font and */ /* color as defined for titles */ rc=gset("texheight", 3); rc=gdraw("text", 125, 1, "GDSORDER "); /* define and draw bar */ rc=gset("lincolor", 2); rc=gset("linwidth", 5); rc=gdraw("line", 2, 72, 72, 30, 70); rc=gdraw("line", 2, 52, 92, 50, 50); /* display graph and end DSGI */ rc=graph("update"); rc=gterm(); run; SAS/GRAPH
goptions colors=(red green blue); data dsname; . . /* other DATA step statements */ . /* associate the bundle with the index 1 */ rc=gset("texrep", 1, 2, "zapf"); . . /* more statements */ . /* assign the text attributes to a bundle */ rc=gset("asf", "texcolor", "bundled"); rc=gset("asf", "texfont", "bundled"); /* draw the text */ rc=gdraw("text", 50, 50, "Today is the day.");
/* invoke the bundle of text attributes */ rc=gset("texindex", 1);
/* define another attribute bundle for text */ rc=gset("texrep", 2, 3, "swiss");
goptions colors=(red green blue); rc=gset("asf", "lincolor", "bundled"); rc=gset("asf", "linwidth", "bundled"); rc=gset("asf", "lintype", "bundled"); rc=gset("linrep", 3, 2, 5, 1);
/* activate the bundle */ rc=gset("linindex", 3); /* select other attributes for the line */ rc=gset("lincolor", 3); rc=gset("linwidth", 10); rc=gset("lintype", 4); /* draw a line from point (30,50) to (70,50) */ rc=gdraw("line", 2, 30, 70, 50, 50);
/* disassociate an attribute from a bundle */ rc=gset("asf", "texcolor", "individual"); rc=gset("asf", "texfont", "individual");
/* define the first viewport, indexed by 1 */ rc=gset("viewport", 1, .05, .05, .45, .45); /* define the second viewport, indexed by 2 */ rc=gset("viewport", 2, .55, .05, .95, .45); /* define the third viewport, indexed by 3 */ rc=gset("viewport", 3, .55, .55, .95, .95); /* define the fourth viewport, indexed by 4 */ rc=gset("viewport", 4, .05, .55, .45, .95);
/* define the window for viewport 1 */ rc=gset("window", 1, 0, 50, 20, 100); /* define the window for viewport 2 */ rc=gset("window", 2, 0, 40, 20, 90); /* define the window for viewport 3 */ rc=gset("window", 3, 10, 25, 45, 100); /* define the window for viewport 4 */ rc=gset("window", 4, 0, 0, 100, 100);
/* define the viewports */ . . . /* define the windows */ . . . /* activate the first transformation */ rc=gset("transno", 1); . . /* graphics primitive functions follow */ . /* activate the second transformation */ rc=gset("transno", 2); . . /* graphics primitive functions follow */ . /* activate the third transformation */ rc=gset("transno", 3); . . /* graphics primitive functions follow */ . /* activate the fourth transformation */ rc=gset("transno", 4); . . /* graphics primitive functions follow */ .
SAS-data-library
refers to a permanent SAS library.
libname local "SAS-data-library"; . . . /* select the output catalog to the */ /* catalog that contains "map" */ rc=gset("catalog", "local", "mapctlg"); . . . /* define the viewport to contain the */ /* existing graph */ rc=gset("viewport", 1, .25, .45, .75, .9); rc=gset("window", 1, 0, 0, 100, 100); /* set the transformation number to the one */ /* defined in the viewport function */ rc=gset("transno", 1); /* insert the existing graph */ rc=graph("insert", "map");
data _null_; length d1-d5 $ 8; input d1-d5; array devices{5} d1-d5; . . . do j=1 to 5; rc=gset("device", devices{j}); . . . rc=ginit(); . . . do i=1 to 5; rc=graph("clear"); rc=gset("filcolor", i); rc=gdraw("bar", 45, 45, 65, 65); rc=graph("update"); end; . . . rc=gterm(); end; cards; tek4105 hp7475 ps qms800 ibm3279 ; run;
/* set the graphics environment */ goptions reset=global gunit=pct border ftext=swissb htitle=6 htext=3 colors=(black blue green red) hsize=7 in vsize=5 in targetdevice=pscolor; /* define the footnote and title */ footnote1 j=r "GDSVTEXT "; title1 "Text Up Vector"; /* execute DATA step with DSGI */ data vector; /* preparesoftware */ /* to accept DSGI statements */ rc=ginit(); rc=graph("clear"); /* define and display arc */ /* with intersecting lines */ rc=gset("lincolor", 2); rc=gset("linwidth", 5); rc=gdraw("arc", 84, 50, 35, 0, 360); rc=gdraw("line", 2, 49, 119, 51, 51); rc=gdraw("line", 2, 84, 84, 15, 85); /* define height of text */ rc=gset("texheight", 5); /* mark 360 degrees on the arc */ /* using default align */ rc=gdraw("text", 121, 50, "0"); /* set text to align to the right and */ /* mark 180 degrees on the arc */ rc=gset("texalign", "right", "normal"); rc=gdraw("text", 47, 50, "180"); /* set text to align to the center and */ /* mark 90 and 270 degrees on the arc */ rc=gset("texalign", "center", "normal"); rc=gdraw("text", 84, 87, "90"); rc=gdraw("text", 84, 9, "270"); /* reset texalign to normal and */ /* display coordinate values or quadrant */ rc=gset("texalign", "normal", "normal"); rc=gdraw("text", 85, 52, "(0.0, +1.0)"); /* rotate text using TEXUP and */ /* display coordinate values or quadrant */ rc=gset("texup", 1.0, 0.0); rc=gdraw("text", 85, 49, "(+1.0, 0.0)"); /* rotate text using TEXUP and */ /* display coordinate values or quadrant */ rc=gset("texup", 0.0, -1.0); rc=gdraw("text", 83, 50, "(0.0, -1.0)"); /* rotate text using TEXUP and */ /* display coordinate values or quadrant */ rc=gset("texup", -1.0, 0.0); rc=gdraw("text", 83, 52, "(-1.0, 0.0)"); /* display graph and end DSGI */ rc=graph("update"); rc=gterm(); run; SAS/GRAPH
/* set the graphics environment */ goptions reset=global gunit=pct border ftext=swissb htitle=6 htext=3 colors=(black blue green red) hsize=7 in vsize=5 in targetdevice=pscolor; /* define the footnote and title */ footnote1 j=r "GDSDIREC "; title1 "Text Path"; /* execute DATA step with DSGI */ data _null_; /* preparesoftware */ /* to accept DSGI statements */ rc=ginit(); rc=graph("clear"); /* define height of text */ rc=gset("texheight", 5); /* display first text */ rc=gdraw("text", 105, 50, "Right"); /* change text path so that text reads from */ /* right to left and display next text */ rc=gset("texpath", "left"); rc=gdraw("text", 65, 50, "Left"); /* change text path so that text reads up */ /* the display and display next text */ rc=gset("texpath", "up"); rc=gdraw("text", 85, 60, "Up"); /* change text path so that text reads down */ /* the display and display next text */ rc=gset("texpath", "down"); rc=gdraw("text", 85, 40, "Down"); /* display the graph and end DSGI */ rc=graph("update"); rc=gterm(); run; SAS/GRAPH
/* set the graphics environment */ goptions reset=global gunit=pct border ftext=swissb htitle=6 htext=4 colors=(black blue green red) hsize=7 in vsize=7 in targetdevice=pscolor; /* create data set TOTALS */ data totals; length dept $ 7 site $ 8; do year=1996 to 1999; do dept="Parts","Repairs","Tools"; do site="New York","Atlanta","Chicago","Seattle"; sales=ranuni(97531)*10000+2000; output; end; end; end; run; /* define the footnote */ footnote1 h=3 j=r "GDSVWPTS "; /* generate pie chart from TOTALS */ /* and create catalog entry PIE */ proc gchart data=totals; format sales dollar8.; pie site / type=sum sumvar=sales midpoints="New York" "Chicago" "Atlanta" "Seattle" fill=solid cfill=green coutline=blue angle=45 percent=inside value=inside slice=outside noheading name="GDSVWPTS"; run; /* define the titles */ title1 "Total Sales"; title2 "For Period 1996-1999"; /* execute DATA step with DSGI */ data piein; /* preparesoftware */ /* to accept DSGI statements */ rc=ginit(); rc=graph("clear"); /* define and activate viewport for inserted graph */ rc=gset("viewport", 1, .15, .05, .85, .90); rc=gset("window", 1, 0, 0, 100, 100); rc=gset("transno", 1); /* insert graph created from GCHART procedure */ rc=graph("insert", "GDSVWPTS"); /* display graph and end DSGI */ rc=graph("update"); rc=gterm(); run; SAS/GRAPH
/* set the graphics environment */ goptions reset=global gunit=pct border ftext=swissb htitle=6 htext=3 colors=(black blue green red) hsize=7 in vsize=5 in targetdevice=pscolor; /* create data set EARN, which holds month */ /* and amount of earnings for that month */ data earn; input month amount; datalines; 1 2.1 2 3 3 5 4 6.4 5 9 6 7.2 7 6 8 9.8 9 4.4 10 2.5 11 5.75 12 4.35 ; run; /* define the footnote for the first graph */ footnote1 j=r "GDSSCALE(a) "; /* define axis and symbol characteristics */ axis1 label=(color=green "Millions of Dollars") order=(1 to 10 by 1) value=(color=green); axis2 label=(color=green "Months") order=(1 to 12 by 1) value=(color=green Tick=1 "Jan" Tick=2 "Feb" Tick=3 "Mar" Tick=4 "Apr" Tick=5 "May" Tick=6 "Jun" Tick=7 "Jul" Tick=8 "Aug" Tick=9 "Sep" Tick=10 "Oct" Tick=11 "Nov" Tick=12 "Dec"); symbol value=M font=special height=8 interpol=join color=blue width=3; /* generate a plot of AMOUNT * MONTH, */ /* and store in member GDSSCALE */ proc gplot data=earn; plot amount*month / haxis=axis2 vaxis=axis1 name="GDSSCALE"; run; /* define the footnote and titles for */ /* second graph, scales the output */ footnote1 j=r "GDSSCALE(b) "; title1 "XYZ Corporation Annual Earnings"; title2 h=4 "Fiscal Year 1999"; /* execute DATA step with DSGI using */ /* catalog entry created in previous */ /* plot, but do not create a data set */ /* (determined by specifying _NULL_) */ data _null_; /* preparesoftware */ /* to accept DSGI statements */ rc=ginit(); rc=graph("clear"); /* define viewport and window for inserted graph */ rc=gset("viewport", 1, .20, .30, .90, .75); rc=gset("window", 1, 15, 15, 95, 75); rc=gset("transno", 1); /* insert graph previously created */ rc=graph("insert", "GDSSCALE"); /* display graph and end DSGI */ rc=graph("update"); rc=gterm(); run; SAS/GRAPH
/* set the graphics environment */ goptions reset=global gunit=pct border ftext=swissb htext=3 colors=(black blue green red) hsize=7 in vsize=5 in targetdevice=pscolor; /* define the footnote for the first graph */ footnote1 j=r "GDSENLAR(a) "; /* execute DATA step with DSGI */ data plot; /* preparesoftware */ /* to accept DSGI statements */ rc=ginit(); rc=graph("clear", "GDSENLAR"); /* define and draw first pie chart */ rc=gset("filcolor", 4); rc=gset("filtype", "solid"); rc=gdraw("pie", 30, 75, 22, 0, 360); /* define and draw second pie chart */ rc=gset("filcolor", 1); rc=gset("filtype", "solid"); rc=gdraw("pie", 30, 25, 22, 0, 360); /* define and draw third pie chart */ rc=gset("filcolor", 3); rc=gset("filtype", "solid"); rc=gdraw("pie", 90, 75, 22, 0, 360); /* define and draw fourth pie chart */ rc=gset("filcolor", 2); rc=gset("filtype", "solid"); rc=gdraw("pie", 90, 25, 22, 0, 360); /* display graph and end DSGI */ rc=graph("update"); rc=gterm(); run; /* define the footnote for the second graph */ footnote1 j=r "GDSENLAR(b) "; /* execute DATA step with DSGI */ /* that zooms in on a section of */ /* the previous graph */ data zoom; /* prepare SAS/GRAPH software */ /* to accept DSGI statements */ rc=ginit(); rc=graph("clear"); /* define and activate a window */ /* that enlarges the lower left */ /* quadrant of the graph */ rc=gset("window", 1, 0, 0, 50, 50); rc=gset("transno", 1); /* insert the previous graph into */ /* window 1 */ rc=graph("insert", "GDSENLAR"); /* display graph and end DSGI */ rc=graph("update"); rc=gterm(); run; SAS/GRAPH
/* execute DATA step with DSGI */ data routine; /* declare character variables used */ /* in GASK subroutines */ length color $ 8; /* preparesoftware */ /* to accept DSGI statements */ rc=ginit(); rc=graph("clear"); /* set color for color index 2 */ rc=gset("colrep", 2, "orange"); /* check color associated with color index 2 and */ /* display the value in the LOG window */ call gask("colrep", 2, color, rc); put "Current FILCOLOR =" color; output; /* end DSGI */ rc=graph("update"); rc=gterm(); run; /* display the contents of ROUTINE */ proc print data=routine; run; SAS/GRAPH
3 /* execute DATA step with DSGI */ 4 data routine; 5 6 /* declare character variables used */ 7 /* in GASK subroutines */ 8 length color $ 8; 9 10 /* preparesoftware */ 11 /* to accept DSGI statements */ 12 rc=ginit(); 13 rc=graph("clear"); 14 15 /* set color for color index 2 */ 16 rc=gset("colrep", 2, "orange"); 17 18 /* check color associated with color index 2 and */ 19 /* display the value in the LOG window */ 20 call gask("colrep", 2, color, rc); 21 put "Current FILCOLOR =" color; 22 output; 23 24 /* end DSGI */ 25 rc=graph("update"); 26 rc=gterm(); 27 run; Current FILCOLOR =ORANGE SAS/GRAPH
The SAS System 13:50 Tuesday, December 22, 1998 1 Obs color rc 1 ORANGE 0