I'm trying to output my PROC GMAP results as a JPEG to put into a presentation. I found an earlier topic and used that code. However, that topic doesn't specify how to edit the name of the resulting JPEG file. Since I need to output a lot of maps, I would like to give each JPEG a name other than "GMAPnn", to make it easier to identify.
1. How do can edit the name of the JPEG file?
2. How do I make that name dynamic to use in a macro?
FILENAME plots "&OUTPATH";
goptions reset=all
DEVICE=jpeg
xpixels=1200
ypixels=1000
transparency
GSFNAME=plots
GSFMODE=REPLACE
NOFILEONLY;
ods _all_ close;
ods listing;
proc gmap map=map data=data;
id ID1;
choro DATA1/
cdefault=gold
coutline=white
legend=legend1;
legend1 value=(h=1 f=arial) label=(h=1 f=arial 'DATA1');
run;
quit;
ods listing close;
Generally, with Proc Gmap, you can use the name= option on the choro statement to control the name of the gseg, and then the name of the gseg is used as the name of the png (or jpeg) image file. The syntax you're using is a bit 'old' ... I would recommend this newer syntax (and I also recommend using png output, rather than jpeg). The following code saves the output as the name 'mymap.png'.
%let name=mymap;
filename odsout '.';
goptions device=png;
ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm" style=htmlblue;
proc gmap map=mapsgfk.us data=mapsgfk.us;
id state;
choro segment / levels=1 nolegend name="&name";
run;
quit;
ODS HTML CLOSE;
ODS LISTING;
Switch to using PROC SGMAP, then you can make use of ODS features.
Hi Kurt,
Thanks for the quick reply. I'm very unfamiliar with SGMAPS and can't quite figure out how to reproduce the map I created using the GMAP procedure.
Could you help me translate the code below into the SGMAP procedure? I'm having trouble defining colors, using the legend and subsetting the data.
pattern1 value=solid color='CXeff3ff';
pattern2 value=solid color='CXbdd7e7';
pattern3 value=solid color='CX6baed6';
pattern4 value=solid color='CX3182bd';
pattern5 value=solid color='CX08519c';
proc gmap map=map data=data;
id ID1;
choro DATA1/
cdefault=white
coutline=white
legend=legend1;
legend1 value=(h=1 f=arial) label=(h=1 f=arial 'DATA1');
where ID2="VALUE";
run;
quit;
I think the NAME option on the CHORO statement will do what you need.
Hope this helps!
Dan
Calling @GraphGuy
Generally, with Proc Gmap, you can use the name= option on the choro statement to control the name of the gseg, and then the name of the gseg is used as the name of the png (or jpeg) image file. The syntax you're using is a bit 'old' ... I would recommend this newer syntax (and I also recommend using png output, rather than jpeg). The following code saves the output as the name 'mymap.png'.
%let name=mymap;
filename odsout '.';
goptions device=png;
ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm" style=htmlblue;
proc gmap map=mapsgfk.us data=mapsgfk.us;
id state;
choro segment / levels=1 nolegend name="&name";
run;
quit;
ODS HTML CLOSE;
ODS LISTING;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.