BookmarkSubscribeRSS Feed
veronicasalmaso
Obsidian | Level 7

Hello SAS experts!
I'm trying to add a text at the bottom of my map:

img0.png

This is the code i used to generate the map: 

proc sgmap plotdata = veneto; 
openstreetmap;
where lon > 10.435428 and lat > 44.847916 and lat < 46.731138; 
scatter x =  lon y = lat / markerattrs=(color=black size=3 symbol=circlefilled); 
run; 

 

 

Since I'm trying to punt the text on the bottom of the map, I added a row with the longitude, latitude and text I want to put on the map.

This is how I made it:

 

data made; 
lat = 44.847916; lon = 10.435428; text = 'Made by';
run; 

DATA veneto;
SET veneto made;
RUN;

proc sgmap plotdata = veneto; 
openstreetmap;
where lon > 10.435428 and lat > 44.847916 and lat < 46.731138; 
scatter x =  lon y = lat / markerattrs=(color=black size=3 symbol=circlefilled); 
TEXT Y=lon X=lat TEXT=text  /TEXTATTRS = (SIZE=12 COLOR='blue');
run; 

The code doesn't generate errors, but when I run the code, the map zooms out and doesn't show any text. 

 

img0.png


What did I do wrong? How can I fix it?
Thank you a lot!

 

(I'm using SAS 9.4m6 release)

 

 

 

4 REPLIES 4
ballardw
Super User

You defined your graph area with lat>44.847916 and then placed your text starting outside of that area at lat =44.847916. Similar with your lon setting. Such things may "confuse" the interface to map data provider.

I suspect that if have the text appear inside the map area that may help. I might try the text at lat=44.85 and lon=10.44.

 

Suggestion: Instead of lat > 44.847916 and lat < 46.731138 you might want to advantage of SAS ability to do comparisons like  46.731138 > lat > 44.847916 . They will be much easier to follow when you haven't looked at this code for a while and may help when you need to change one element.

 

Another. You might see just how many of those decimal places are actually needed.

 

Another thing I would suggest is to set the text size with a unit of measure such as:

TEXT Y=lon X=lat TEXT=text  /TEXTATTRS = (SIZE=12PT COLOR='blue');

The units for "size" can be a bit of a problem, especially if using code that may bury option settings  and in some cases can result in unreadable text. If you control the units then you don't run into text too small to see, default pixels is machine dependent and what appears okay running on one machine can render text next to invisible on ultrahigh resolution devices.

veronicasalmaso
Obsidian | Level 7
@ballardw Thank you for your reply!
Your suggestions made the code easier to read. Unfortunately, even changing lat to 44.85 and lon to 10.44, the map stills zooms out like before the changes
ballardw
Super User

Try commenting out the Scatter statement and play with the coordinates of the TEXT until the text appears in the desired map area. My "guess" on the coordinates might still have had text appearing outside of the intended area because of the height of letters displayed, which might be a cause of the zoom. If you get the text to appear in the area without the scatter then add the scatter.

 

You might also need upper and lower limits on LON and not just LAT.

veronicasalmaso
Obsidian | Level 7
I tried both changing the coordinates to a point exactly in the middle of the map and also commenting out the scatter statement.
The text doesn't appear, even if use a bigger o smaller size. When I comment out the scatter, the map zooms in the middle of a lake, no matter what coordinates I put in (I even tried changing them to lat = 0 and lon = 0)

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 583 views
  • 0 likes
  • 2 in conversation