I have a US map produced from the GMAP procedure with a choropleth variable which has the 5 possible values formatted with Proc Format. Below are those parts of my code.
I am using GREPLAY to produce a template which includes the US map, and the 5 US territories in 5 small insets on the right side. I have the template working for the insets, but not the main US map. The legend for the choropleth varaible (same for each map) needs to be an independent panel so that the US map is not stretched. I found how to separate the legend using GPLOT with the noaxes and noframe options, but I cannot find a way to produce JUST this legend with the specified colors and values from the GMAP procedure. Once I have the legend separate, I can assign it to a panel in greplay.
For titles and footnotes, will the GSLIDE procedure still work with multiple title and footnote statements (subtitles, sub-footnotes), and which have varying formatting and embedded unicode?
proc format ;
value Risk
0 = 'No Data Available'
1 = 'Low'
2= 'Moderately Low '
3 = 'Moderately High '
4 = 'High ';
run;
goptions reset=all;
pattern1 value=m3N45 color=black;
pattern2 value=msolid color=BILG;
pattern3 value=msolid color=gold;
pattern4 value=msolid color=orange;
pattern5 value=msolid color=VIYPK;
legend1 label=(justify=c "State Risk Score (1-Lowest to 4-Highest)")
value=(tick=1 justify=l
tick=2 justify=l
tick=3 justify=l
tick=4 justify=l
tick=5 justify=l);
goptions xpixels=800 ypixels=800;
proc gmap data=my_map map=my_map anno=anno_shadow all;
id statecode;
choro risk_score / legend=legend1 levels=5 midpoints=(0 1 2 3 4 ) anno=anno_all
des='' name='states50';
run;
There is no reason that a Legend per se would "stretch" any map.
I would suggest that you consider the template set up as the cause as it sounds like the height to width ration of the replay cell has a different ratio than your map.
This link https://support.sas.com/kb/24/945.html shows one way to accomplish this. There are bits about a common title as well. The example provides 1) data to display 2) Code including the graphs and proc template and the example to display the results.
Try creating the output without the legend, and see if you're still getting the 'stretching' problem. Alternatively, try using mode=share for the legend, so that the legend shouldn't affect the size or position of the legend. To help further diagnose the problem, it would help to show the code that creates your custom greplay template, and also what some sample output looks like.
I tried adding that option to the legend, and now the output in the SAS results window looks great but the PDF file is stretched horizontally. I've tried changing the orientation but that distorts it even more @GraphGuy I used code from your example here (http://robslink.com/SAS/democd93/panama_inset_map.sas). I want to keep the border detail on the inset maps for the 5 territories, so I removed the xpixel and ypixel options from the GMAP procedures for each. This didn't seem to change the output from the GREPLAY procedure. I also want the titles and footnotes to appear on the PDF, but none of those are showing. I do see them on the results window.
I am having issues with how the separate territory maps look for a couple of them, but I'll raise that in another posting.
goptions xpixels=800 ypixels=800;
options orientation=landscape papersize=legal;
ODS pdf style=sasweb file='...US_ALL.pdf' ;
proc greplay tc=tempcat nofs igout=work.gseg;
tdef crmap des='crmap'
1/llx = 0 lly = 0
ulx = 0 uly = 80
urx =80 ury = 80
lrx =80 lry = 0
2/llx = 86 lly = 78
ulx = 86 uly = 90
urx =98 ury = 90
lrx =98 lry = 78
3/llx = 86 lly = 63
ulx = 86 uly = 75
urx = 98 ury = 75
lrx = 98 lry = 63
4/llx = 86 lly = 48
ulx = 86 uly = 60
urx = 98 ury = 60
lrx = 98 lry = 48
5/llx = 86 lly = 33
ulx = 86 uly = 45
urx = 98 ury = 45
lrx = 98 lry = 33
6/llx = 86 lly = 18
ulx = 86 uly = 30
urx = 98 ury = 30
lrx = 98 lry = 18
;
title1 c=gray33 f='albany amt' h=16pt "US Map States and Territories";
title2 c=gray33 f='albany amt' h=12pt 'Date: July 2020';
title3
c=red h=12pt f='albany amt/unicode' '2605'x
c=gray33 f='albany amt' h=10pt " 5"
c=orange h=12pt f='albany amt/unicode' '2605'x
c=gray33 f='albany amt' h=10pt "4"
c=DAY h=12pt f='albany amt/unicode' '2605'x
c=gray33 f='albany amt' h=10pt "3";
title4
c=black h=12pt f='albany amt/unicode' '2605'x
c=gray33 f='albany amt' h=10pt "1 or 2";
footnote1 c=gray33 f='albany amt' h=8pt "footnote1";
footnote2 c=gray33 f='albany amt' h=8pt "footnote2" ;
footnote3 c=gray33 f='albany amt' h=8pt "footnote3"
;
template = crmap;
treplay
1:states50
2:PRMAP
3:VIMAP
4:GUMAP
5:ASMAP
6:MPMAP
des='' ;
run;
quit;
ODS pdf CLOSE;
ODS LISTING;
I'm not sure what advice to give on pdf output.
Would you be able to create png output, and then include the png image into your pdf?
Are you using gtitles? (ie, are the titles part of the png image, or outside of the png image and part of the html? I think Enterprise Guide defaults to nogtitles) Also, what font are you using? How are you submitting the SAS job? (batch sas, DMS Windows SAS, Enterprise Guide, other?) Maybe try ods html rather than ods html5.
I think in EG you have to go through the menus and change some setting to get the gtitles and gfootnotes (rather than using the code options). I'm not an EG user, so I'm not sure what menu to point you towards, but maybe @ChrisHemedinger can point you in the right direction for that!
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.