Data visualization with SAS programming

Exporting a map from proc gmap

Accepted Solution Solved
Reply
Contributor
Posts: 55
Accepted Solution

Exporting a map from proc gmap

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

image.png

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;

ok6regions3.pngis there some other code I can use to simply export the file as I see it in my sas output screen?

 


Accepted Solutions
Solution
‎11-15-2016 04:55 PM
Contributor
Posts: 55

Re: Exporting a map from proc gmap

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;

View solution in original post


All Replies
Grand Advisor
Posts: 9,714

Re: Exporting a map from proc gmap

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.

 

 

Contributor
Posts: 55

Re: Exporting a map from proc gmap

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.

Attachment
Grand Advisor
Posts: 9,714

Re: Exporting a map from proc gmap

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.

Solution
‎11-15-2016 04:55 PM
Contributor
Posts: 55

Re: Exporting a map from proc gmap

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;
Post a Question
Discussion Stats
  • 4 replies
  • 175 views
  • 0 likes
  • 2 in conversation