I am new to SAS and want to make a macro procedure that creates y-axis values for a later PROC GPLOT.
In plain English, there are two posssible minimum values (and maxs) on this graph. The axis range is dependent on which minimum value is the smallest. Otherwise, SAS will not display data outside the axis range. I do NOT want SAS to automatically create the range for me. I want to define the range myself.
So, this is my attempt at a procedure that a) calculates two minimum values, b) compares the two, and c) stores the smaller of the two in a new macro variable. If I can get this one to work, a max procedure would be easy to do.
%MACRO min;
%LET ymin1 = %SYSEVALF(&minresult - (((&minresult + &maxresult)/2) * .05);
%PUT ymin1 = &ymin1;
%LET ymin2 = %SYSEVALF(&min - (&min * .05));
%PUT ymin2 = &ymin2;
%IF &ymin1 > &ymin2
%THEN %LET ymin = ymin2;
%ELSE %LET ymin = ymin1;
%PUT ymin = &ymin;
%MEND min;
I have a feeling I am doing something wrong syntactically. Any help is appreciated.
macro
is the term itself.PROC FCMP
allows you to create functions and procedures, but they're not in the macro language - rather in something close to the data step language. Also, you should define &min/&minresult/&max/&maxresult as macro parameters; even if they exist as global macro variables, it's better style-wise to define them again. You can still call %min(&min,&max,&minresult,&maxresult) and it will work fine. – Joe