I created a state map using the following code below, but now I'd like to export the graph as a high quality image in png or jpeg format.
proc gmap data=graph map=graph all resolution=6 ; id state county_codex; choro region / discrete legend=legend2 coutline=black anno=annoreg; legend1 shape=bar(4,3) pct across=5 frame cshadow=black label=none; legend2 label=(position=top j=center h=1 position=(top) color=black "Region Names") position=(bottom left outside) shape=bar (4,3) value=(c=black j=l h=1) frame across=5 cborder=black ; run;
The sas output in SAS looks like this
However, when I add the following code before running proc gmap in an attempt to export the map as a png, the image of my map suddenly shrinks and my legend enlarges.
FILENAME plots "C:\Users\"; goptions reset=all DEVICE=png300 transparency GSFNAME=plots GSFMODE=REPLACE NOFILEONLY; ods _all_ close; ods listing;
is there some other code I can use to simply export the file as I see it in my sas output screen?
Not sure if this is what fixed it, but adding in "mode=share" seems to have solved the problem. That, and I changed the format to gif. Now it works like a charm.
Thanks for your help!
FILENAME plots "C:\Users\"; goptions reset=all DEVICE=gif xpixels=1200 ypixels=1000 transparency GSFNAME=plots GSFMODE=REPLACE NOFILEONLY; ods _all_ close; ods listing; proc gmap data=graph map=graph all /*resolution=6 */; id state county_codex; choro region / discrete legend=legend2 coutline=black anno=annoreg name="ok"; legend2 label=(position=top j=center h=1 position=(top) color=black "Region Names") position=(bottom left outside) shape=bar (4,3) value=(c=black j=l h=1) frame across=6 cborder=black mode=share ; run; quit; ods listing close;
You may need to specify actual units for things. I believe the default GUNIT=Cells may be getting interpretted to make the text bigger in relation to the graph. Also you may want to look at the TARGETDEVICE setting to match your actual output destination. If the "target" destination remains the likely default of PNG then the number of pixels generated for the image are significantly fewer than PNG300 so the result can get a result similar to what you show.
So I tried targetdevice=png300 gunit=cells hsize=3 vsize=1 and that makes the map of OK bigger, but still not big enough but now the legend is too small and is way to the left. Is there something else I need to specify? I feel like I'm missing some other syntax.
You can use a different GUNIT than cells, please look at the documentation. Also you can get some unexpected, until you use it a lot, results from the SYS options which describe how much and how to divide up the graphic area.
I spend a fair amount of time with legends setting text and offset options for things to appear where desired.
You may want to look at legend options of inside share.
Not sure if this is what fixed it, but adding in "mode=share" seems to have solved the problem. That, and I changed the format to gif. Now it works like a charm.
Thanks for your help!
FILENAME plots "C:\Users\"; goptions reset=all DEVICE=gif xpixels=1200 ypixels=1000 transparency GSFNAME=plots GSFMODE=REPLACE NOFILEONLY; ods _all_ close; ods listing; proc gmap data=graph map=graph all /*resolution=6 */; id state county_codex; choro region / discrete legend=legend2 coutline=black anno=annoreg name="ok"; legend2 label=(position=top j=center h=1 position=(top) color=black "Region Names") position=(bottom left outside) shape=bar (4,3) value=(c=black j=l h=1) frame across=6 cborder=black mode=share ; run; quit; ods listing close;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: