Hello SAS experts!
I'm trying to add a text at the bottom of my map:
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.
What did I do wrong? How can I fix it?
Thank you a lot!
(I'm using SAS 9.4m6 release)
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.
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.