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

Hello,

I am having trouble outputting a GMAP procedure to a PDF file when using tiles from Open Street Map in SAS v9.4.

 

When I run the gmap procedure to ODS listing, the map appears as it should (image attached):

ods listing.PNGCapture.PNG

 

However, when I try to use ODS PDF the background image tiles do not appear. Only the annotated "dots" appear. 

 

 

 

I am using the SAS annotate generator, described in the paper "Google-Like Maps in SAS" by Darrell Massengill. The code for the OSM annotate generator is available here: http://support.sas.com/rnd/papers/sasgf13/GooglelikeMaps.zip 

 

/*location of the programs */
libname OAG 'H:\GooglelikeMaps\AFpgm';


/*Reset macro variables*/
%include 'H:\GooglelikeMaps\AFpgm\OAG_reset.sas';

/* Subdivision Residences */
data residences;
input y x rec_no;
cards;
35.8997 -75.6403 1
35.8937 -75.6448 2
35.9096 -75.6463 3
;
run;



/*-----------------------------------------------------------*/
/* Macro to create point data in an annotate data set*/
%macro make_dots(annodata, inputdata, color, size, tipvar); 
data &annodata;
length function color $ 8 style $20 position $ 1 text $ 60 html $1024;
retain xsys ysys '2' hsys '3' when 'a' size .7;
set &inputdata;
/*optional arguments*/
%if (&size ^= ) %then %do;
size=&size;
%end;
/* All annotate points are 360-degree pies. */
function='pie';
rotate=360;
style='psolid';
color=&color;

/* optional tool tips */
%if (&tipvar ^= ) %then %do;
html= 'title=' || quote("&tipvar" ||'=' || 
trim(left(&tipvar)) );
%end;


output;
/* Draw an outline around each 'dot' */
color="gray55"; style='pempty';
output;
run;
%mend;

/*-----------------------------------------------------------*/




/* Create annotate data set of dots at locations */
%make_dots(annodots, residences,'RED');





/* Set the macro variables for the OSM Generator */
%let _backgroundonly='YES';
%let _inannods=annodots;
%let _outannods=mannodots;
%let _outmapds=mmap;
%let _outannoOSMds=work.mannoosm;
%let _imageloc='/cma/nshare/bokerson/OSMMaps/';
%let _xpixels=800;
%let _ypixels=600;
%let _autoproject='Y';
%let _tileserv="SAS";
goptions reset;
goptions xpixels=&_xpixels ypixels=&_ypixels xmax=12in ymax=9in;


/* Generate background image */
PROC DISPLAY cat=OAG.osmmapanno.osm_anno_gen.scl; run;


/*Combine the annotate data sets - The background and the dots*/
data bothanno;
set &_outannoOSMds mannodots;
run;


/* Generate the map*/
ODS _all_ CLOSE;
ODS PDF file="H:\output\testgroup1.pdf" STARTPAGE = NO NOGTITLE;
pattern;
pattern v=me c=A00000000 r=100;
PROC GMAP map=&_outmapds anno=bothanno data=&_outmapds all;
id id;
choro id /nolegend name="PC_ALT";
run;
quit;
ODS PDF CLOSE;
ODS LISTING;

 

1 ACCEPTED SOLUTION

Accepted Solutions
chelepi
Calcite | Level 5

The OSM tiles still did not appear when I removed the annotations and when I wrote the annotations first.

 

However, I got it to work by writing the OSM tiles first. Thank you for that suggestion. 

 

I just added the following after the Proc Display. 

DATA mannoosm;
	SET mannoosm; 
	WHEN = 'B';
	run; 

View solution in original post

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

What happens if there are no annotations?

What happens if the annotations are written first (WHEN='B') ?

 

 

chelepi
Calcite | Level 5

The OSM tiles still did not appear when I removed the annotations and when I wrote the annotations first.

 

However, I got it to work by writing the OSM tiles first. Thank you for that suggestion. 

 

I just added the following after the Proc Display. 

DATA mannoosm;
	SET mannoosm; 
	WHEN = 'B';
	run; 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 643 views
  • 0 likes
  • 2 in conversation