The SAS Output Delivery System and reporting techniques

macros & if/then statements with footnotes and reflines in sgplots

Reply
Regular Contributor
Regular Contributor
Posts: 170

macros & if/then statements with footnotes and reflines in sgplots

Hello all-
another possible brain teaser that any assistance would be much appreciated-

I have a macro that takes all the units and produces a graph for each unit. So far, no difficulty except that I would like to change two things:

Based on a specific unit I would to be able to change the refline statement as needed.

Also, is there is any way to use if/then statements in the footnotes of each graph that incorporate data from other macros-

The code is shown below, any assistance much appreciated!
LB


%macro split (data=, var=);
proc sort data=&data(keep=&var) out=values nodupkey;
by &var;
run;
data _null_;
set values end=last;
call symputx('site'||left(_n_),&var);
if last then call symputx('count',_n_);
run;
%put _local_;


DATA _NULL_ ;
select(&var);
%do i=1 %to &count;


/*CRBSI GRAPHS */

ODS GRAPHICS ON /IMAGEFMT=PNG HEIGHt=3in width=5in SCALE=OFF ANTIALIAS=ON IMAGENAME="CRBSI_&&site&i" BORDER=NO;
title "&&site&i";

proc sgplot data=BASIC_OUT_II NOAUTOLEGEND ;
WHERE UNIT1 IN ("&&site&i") and _type_ =7 and moi>'30Aug07'd;


series x=Moi2 y=CRBSI_RATE /
datalabel=CRBSIgraph
lineattrs=(pattern=solid thickness=2px color=blue)
markerattrs=(symbol=circlefilled )

markers group=UNIT1;
yaxis label='CRBSI Rate per 1000 DD' GRID VALUES = (0 TO 15 BY 2.5);
xaxis label =' ';
REFLINE 4.56 / TRANSPARENCY = .1 LINEATTRS=(pattern=dot thickness=3px color=green)
LABEL = ('UCSF IAP Goal:4.56') LABELLOC=OUTSIDE ;
REFLINE .5 / TRANSPARENCY = .1 LINEATTRS=(pattern=dot thickness=3px color=red)
LABEL = ('NHSN 25%ile (.5)' ) LABELLOC=OUTSIDE ;
run;

footnote goes here.

ODS GRAPHICS OFF;
Super Contributor
Super Contributor
Posts: 3,174

Re: macros & if/then statements with footnotes and reflines in sgplots

The SAS macro language also has %IF / %THEN logic, and you can use SAS macro variables which get resolved at SAS compilation time - you can use macro variables you name in your program to substitute string values, such as you mentioned with your REFLINE.

Have a look at the SAS support website http://support.sas.com/ where there is SAS-hosted documentation, specifically the SAS MACRO LANGUAGE documentation.


Scott Barry
SBBWorks, Inc.
Super Contributor
Super Contributor
Posts: 3,174

Re: macros & if/then statements with footnotes and reflines in sgplots

The SAS macro language also has %IF / %THEN logic, and you can use SAS macro variables which get resolved at SAS compilation time - you can use macro variables you name in your program to substitute string values, such as you mentioned with your REFLINE.

Have a look at the SAS support website http://support.sas.com/ where there is SAS-hosted documentation, specifically the SAS MACRO LANGUAGE documentation.


Scott Barry
SBBWorks, Inc.
Super Contributor
Super Contributor
Posts: 3,174

Re: macros & if/then statements with footnotes and reflines in sgplots

The SAS macro language also has %IF / %THEN logic, and you can use SAS macro variables which get resolved at SAS compilation time - you can use macro variables you name in your program to substitute string values, such as you mentioned with your REFLINE.

Have a look at the SAS support website http://support.sas.com/ where there is SAS-hosted documentation, specifically the SAS MACRO LANGUAGE documentation.


Scott Barry
SBBWorks, Inc.
Super Contributor
Super Contributor
Posts: 3,174

Re: macros & if/then statements with footnotes and reflines in sgplots

The SAS macro language also has similar IF / THEN logic using percent signs, and you can use SAS macro variables which get resolved at SAS compilation time - you can use macro variables you name in your program to substitute string values, such as you mentioned with your REFLINE.

Have a look at the SAS support website http://support.sas.com/ where there is SAS-hosted documentation, specifically the SAS MACRO LANGUAGE documentation.


Scott Barry
SBBWorks, Inc.
Super Contributor
Super Contributor
Posts: 3,174

Re: macros & if/then statements with footnotes and reflines in sgplots

The SAS macro language also has %IF / %THEN logic, and you can use SAS macro variables which get resolved at SAS compilation time - you can use macro variables you name in your program to substitute string values, such as you mentioned with your REFLINE.

Have a look at the SAS support website http://support.sas.com/ where there is SAS-hosted documentation, specifically the SAS MACRO LANGUAGE documentation.


Scott Barry
SBBWorks, Inc.
Super Contributor
Super Contributor
Posts: 3,174

Re: macros & if/then statements with footnotes and reflines in sgplots

The SAS macro language also has %IF / %THEN logic, and you can use SAS macro variables which get resolved at SAS compilation time - you can use macro variables you name in your program to substitute string values, such as you mentioned with your REFLINE.

Have a look at the SAS support website http://support.sas.com/ where there is SAS-hosted documentation, specifically the SAS MACRO LANGUAGE documentation.


Scott Barry
SBBWorks, Inc.
Super Contributor
Super Contributor
Posts: 3,174

Re: macros & if/then statements with footnotes and reflines in sgplots

The SAS MACRO language has macro variables used for data passing (using the %GLOBAL) and substituation (for example, in your REFLINE and FOOTNOTEn statement). Also, the macro language has %IF / %THEN statements you can use for conditional logic processing, as you have requested. Have a look at the SAS product documentation's Macro Language manual at the SAS support website http://support.sas.com/ for details and syntax coding.

Scott Barry
SBBWorks, Inc.
Super Contributor
Super Contributor
Posts: 3,174

Re: macros and if/then statements with footnotes and reflines in sgplots

The SAS MACRO language has macro variables used for data passing (using the %GLOBAL) and substituation (for example, in your REFLINE and FOOTNOTEn statement). Also, the macro language has %IF / %THEN statements you can use for conditional logic processing, as you have requested. Have a look at the SAS product documentation's Macro Language manual at the SAS support website http://support.sas.com/ for details and syntax coding.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 8 replies
  • 201 views
  • 0 likes
  • 2 in conversation