/******************************************************************************/ /* */ /* This example simulates the GRAPH window when a SAS/GRAPH procedure is */ /* uses BY group processing. The GRAPH window allows you to scroll */ /* forward and backward through the generated graphs. In FRAME using */ /* a SAS/GRAPH Output object, this is not possible. You must program */ /* it. */ /* The FRAME contains the following: */ /* */ /* Name Object */ /* ---------------------------- */ /* GRAPH SAS/GRAPH Output */ /* PREVIOUS Control Object with UP arrow */ /* NEXT Control Object with DOWN arrow */ /* */ /******************************************************************************/ INIT: length memname libname objname objtype $ 8; LIBNAME=''; MEMNAME=''; OBJNAME=''; OBJTYPE=''; control asis; if exist('work.gseg','catalog') then rc=delete('work.gseg','catalog'); submit continue; /* Set goptions */ goptions device=xcolor nodisplay hby=.5cm cby=blue fby=swiss; /* Set display options */ axis1 label=(color=black height=2 font=swiss 'Asking Price') value=(color=blue font=swiss) offset=(4,4); axis2 label=(angle=0 rotate=0 height=2 color=black font=swiss 'Square' j=left 'Footage') value=(color=blue font=swiss); /* Set the plotting symbol */ symbol1 value=square color=red; /* Sort the data set and run the GPLOT procedure. */ proc sort data=sasuser.houses; by style bedrooms; proc gplot data=sasuser.houses; title1 c=blue font=swiss h=1cm 'Plot of Square Feet by Asking Price'; by style bedrooms; plot sqfeet*price/ haxis=axis1 vaxis=axis2; run; quit; /* Set GOPTIONS DISPLAY */ goptions display; /* Create WORK.TEMP data set */ proc sql; create table work.temp as select * from dictionary.catalogs where libname='WORK' and memname='GSEG' and objtype='GRSEG' order by alias; quit; endsubmit; /* Open WORK.TEMP */ if exist('work.temp') then dsid=open('work.temp'); else do; _msg_='Data set does not exist.'; return; end; /* Determine the number of observations in WORK.TEMP and /* use the CALL SET to map variables in data set with /* SCL variables. nobs=attrn(dsid,'nobs'); call set(dsid); count=0; goto next; return; NEXT: count=count+1; if count>nobs then do; count=count-1; _msg_='At Bottom...'; return; end; else link gengraph; return; PREVIOUS: count=count-1; if count=0 then do; count=count+1; _msg_='At Top...'; return; end; else link gengraph; return; GENGRAPH: rc=fetchobs(dsid,count); _msg_='Select DOWN arrow to view next graph or UP arrow' ||' to view previous graph.'; /* Assign the graph name to the SAS/GRAPH Output object */ graph=libname||'.'||memname||'.'||objname; return; TERM: dsid=close(dsid); return;