/* This file contains graphical settings for obtaining a consistent layout of the graphs in the programs of the homepage. */ %macro basic_settings; /* Choosing a suitable device for displaying the graphs on the screen. The variable &sysscp, which holds the name of the host system, is used to automatically choose a proper device. Default device is set to 'xcolor'. If run on Windows the device is changed to 'win'. If the chosen device is not available on the system, the user is prompted for device. */ %let device = xcolor; %if %quote(&sysscp) = WIN %then %let device = win; /* setting common graphical parameters */ GOPTIONS GUNIT = pct HTITLE = 6 HTEXT = 4 DEVICE = &device /* other choices like jpg, pdf, ps etc. also works fine */ FTEXT = swiss FTITLE = swiss CBACK = white CSYMBOL = black ; RUN; %mend basic_settings; /* Invoking the basic graphical settings */ %basic_settings; /* Global settings for symbol size, line width and symbol type */ SYMBOL1 HEIGHT = 3 WIDTH = 2 VALUE = CIRCLE; SYMBOL2 HEIGHT = 3 WIDTH = 2 VALUE = CIRCLE; SYMBOL3 HEIGHT = 3 WIDTH = 2 VALUE = CIRCLE; SYMBOL4 HEIGHT = 3 WIDTH = 2 VALUE = CIRCLE; SYMBOL5 HEIGHT = 3 WIDTH = 2 VALUE = CIRCLE; SYMBOL6 HEIGHT = 3 WIDTH = 2 VALUE = CIRCLE; /* The following are macros defined for setting suitable dimensions of the figure. Unless otherwise stated in a program, we use dimensions corresponding to 1 graph only. Macros for obtaining multiple graphs in one figure are found below and are somewhat inspired by the program at http://support.sas.com/kb/24/939.html */ /* Macro for graphical settings to be set BEFORE specifying the plots */ %macro begin_multilayout(rows, cols); %global hsize; %global vsize; /* resetting graphical variables to default for the chosen device */ GOPTIONS HSIZE = 0 VSIZE = 0 HPOS = 0 VPOS = 0; %let aspect = 1.2; /* so xaxis = aspect times yaxis */ DATA dimensions; rc = ginit(); /* Start Data Step Graphics Interface (DSGI). rc = return code. */ call gask('hsize', defhsize, rc); /* Get default HSIZE for the device */ call gask('vsize', defvsize, rc); /* Get default VSIZE for the device */ vside = min(defhsize/(&cols*&aspect), defvsize/&rows); /* vertical side of panel */ hside = vside * &aspect; /* horizontal side of panel */ hsize = &cols * hside; /* horizontal side of entire plot */ vsize = &rows * vside; /* vertical side of entire plot */ call symput('hsize',left(trim(hsize))); call symput('vsize',left(trim(vsize))); call symput('hside',left(trim(hside))); call symput('vside',left(trim(vside))); rc = gterm(); /* Terminate DSGI */ RUN; /* Setting a plot are suitable for the panels */ GOPTIONS HSIZE = &hside VSIZE = &vside NODISPLAY; %mend begin_multilayout; /* As default we set a layout with 1 graph only */ %begin_multilayout(1,1); GOPTIONS DISPLAY; /* macro for graphical settings to be set AFTER specifying the plots */ %macro end_multilayout(rows, cols); /* Setting the size for the entire image */ GOPTIONS HSIZE = &hsize VSIZE = &vsize HPOS = 0 VPOS = 0 DISPLAY; /* Defining the template with specified number of columns resp. rows */ %let npanels = %eval(&rows*&cols); %let hstep = %eval(100/&cols); %let vstep = %eval(100/&rows); /* Calculate the panel coordinates */ DATA positions; /* horizontal coordinates for the 4 corners of each graph */ DO x = 0 to (100 - &hstep) by &hstep; llx = x; /* lower left */ ulx = x; /* upper left */ urx = x + &hstep; /* upper right */ lrx = x + &hstep; /* lower right */ /* vertical coordinates */ DO y = 0 to (100 - &vstep) by &vstep; lly = y; uly = y + &vstep; ury = y + &vstep; lry = y; OUTPUT; END; END; RUN; PROC SORT; BY DESCENDING y; RUN; DATA positions; SET positions; call symput('llx'||left(_n_),llx); call symput('ulx'||left(_n_),ulx); call symput('urx'||left(_n_),urx); call symput('lrx'||left(_n_),lrx); call symput('lly'||left(_n_),lly); call symput('uly'||left(_n_),uly); call symput('ury'||left(_n_),ury); call symput('lry'||left(_n_),lry); run; /* The template definition using calculated positions*/ %macro create_template; %do i = 1 %to &npanels; &i /llx=&&llx&i lly=&&lly&i ulx=&&ulx&i uly=&&uly&i urx=&&urx&i ury=&&ury&i lrx=&&lrx&i lry=&&lry&i %end; %mend create_template; /* Which graphs to replay and their position in the template. Graph number "i" will be placed in the "i"'th panel. There will be given a warning if graph "i" does not exist, ie. there are more panels than graphs */ %macro treplay; %do i=1 %to &npanels; &i:&i %end; %mend treplay; /* Now replay the graphs */ PROC GREPLAY IGOUT = plots /* catalog of plots */ TC = template_catalog /* catalog to save templates */ NOFS; /* line mode */ TDEF template %create_template; /* defining the template "template" */ TEMPLATE template; TREPLAY %treplay; QUIT; RUN; QUIT; %mend end_multilayout;