Esteemed Advisers:
I'm having an issue with Macros.
The code below runs two instances of a routine to draw a polygon.
In Macro Test A, I use two macros statements. The first, &RoI, sets the size of Region of Interest and is used to reference the appropriate dataset. The second, &Corner, sets the locations of the corners of the RoI in the Annotation Dataset used to construct the polygon. The result (see attached pdf), shown as a plot labeled Macro Test A, displays the polygon as expected.
In Macro Test B, I also use two macros, but in this case, &Corner is defined in terms of &RoI. The result (see attached pdf), shown in the plot labeled Macro Test B shows that the polygon is not drawn. Perhaps a macro can't reference another macro? If so, is there another way to automatically set the corners of the polygon from &RoI?
Thanks for your help.
Gee
/*MACRO TEST A*/
/*Create macro to select dataset for Region of Interest (work.test&RoI)*/
%LET RoI=460;
/*Create macro to locate corners of Region of Interest for polygon annotation*/
%LET Corner=230;
/*Annotation dataset for region of interest polygon*/
data anno_poly;
length xc1 yc1 $10 function $50;
linethickness=2;
layer='front';
x1space='datavalue';
y1space='datavalue';
function='polygon';
xc1='-&Corner';
yc1='-&Corner';
output;
function='polycont';
xc1='&Corner';
yc1='-&Corner';
output;
xc1='&Corner';
yc1='&Corner';
output;
xc1='-&Corner';
yc1='&Corner';
output;
data work.test&RoI;
do ty=1 to 400 by 10;
do tx=1 to 400 by 10;
k=0;
end;
end;
ods graphics / reset width=6.4in height=6.4in imagemap;
proc sgplot data=work.test&RoI sganno=anno_poly aspect=1;
title height=12pt "Macro Test A";
heatmapparm x=tx y=ty colorgroup=k;
xaxis label='KM' valuesrotate=vertical grid values=(-400 to 400 by 25)
fitpolicy=rotatethin;
yaxis label='KM' grid values=(-400 to 400 by 25) fitpolicy=thin;
run;
/*MACRO TEST B*/
/*Create macro to select dataset for Region of Interest (work.test&RoI)*/
%LET RoI=460;
/*Create macro to locate corners of Region of Interest for polygon annotation*/
%LET Corner=&RoI/2;
/*Annotation dataset for region of interest polygon*/
data anno_poly;
length xc1 yc1 $10 function $50;
linethickness=2;
layer='front';
x1space='datavalue';
y1space='datavalue';
function='polygon';
xc1='-&Corner';
yc1='-&Corner';
output;
function='polycont';
xc1='&Corner';
yc1='-&Corner';
output;
xc1='&Corner';
yc1='&Corner';
output;
xc1='-&Corner';
yc1='&Corner';
output;
data work.test&roi;
do ty=1 to 400 by 10;
do tx=1 to 400 by 10;
k=0;
end;
end;
ods graphics / reset width=6.4in height=6.4in imagemap;
proc sgplot data=work.test&roi sganno=anno_poly aspect=1;
title height=12pt "Macro Test B";
heatmapparm x=tx y=ty colorgroup=k;
xaxis label='KM' valuesrotate=vertical grid values=(-400 to 400 by 25)
fitpolicy=rotatethin;
yaxis label='KM' grid values=(-400 to 400 by 25) fitpolicy=thin;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.