BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
einstein
Quartz | Level 8

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?

 

1 ACCEPTED SOLUTION

Accepted Solutions
einstein
Quartz | Level 8

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

4 REPLIES 4
ballardw
Super User

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.

 

 

einstein
Quartz | Level 8

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.


ok6regions9.png
ballardw
Super User

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.

einstein
Quartz | Level 8

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;

sas-innovate-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 3720 views
  • 0 likes
  • 2 in conversation