BookmarkSubscribeRSS Feed
Tommer
Obsidian | Level 7

Hello!

I am trying to use sas mapsgfk.world dataset. I have a separate dataset where latitudes and longitudes are collected in decimal degrees. Mapsgft.world has LONG, LAT, X and Y variables.

The values in LONG, LAT doesn't match entirely with the dataset I have. 

Ex: From within united states, I have co-ordinates longitude: -164.7520065 and latitude:64.4912815 in my dataset however, this does not match any latitude longitude co-ordinates from mapsgfk.world so I can use these as id variables in proc gmap.

 

Any thoughts please?

11 REPLIES 11
Reeza
Super User
Why would you expect them to match exactly?
The maps data set is a boundary file designed to map the world entirely, it doesn't have every point mapped.

What are you trying to do that you think will not work?
Have you tried a basic SGMAP to visualize your data?
Tommer
Obsidian | Level 7
Thanks Reeza! So when I tried to map the co-ordinates I have using proc gmap and using Mapsgft.world and id variable as LONG, LAT nothing showed up, not even the world map. Hence I started to wonder if they have to match the co-ordinates exactly.

I have not used proc sgmap.
Reeza
Super User
ID variable should be what unique identifies your points, not your lat/long either way. So each location should have a unique ID. It's not as important for point data - it's more important for spatial data where the ID helps to identify a unique polygon or shape.

https://support.sas.com/rnd/datavisualization/mapsonline/html/geocode_gmap.html
Tommer
Obsidian | Level 7
This is what I am doing since 'long' is unique to each record:
My dataset:
Common_name lat long bucket
Bar-tailed Godwit 64.4912815 -164.7520065 5
Bar-tailed Godwit 37.0946519 -122.2786759 1
Bar-tailed Godwit 34.6303 -76.5328 1
Bar-tailed Godwit 44.5088097 -124.0803623 1
Bar-tailed Godwit 41.373717 -112.133503 1
Bar-tailed Godwit 46.516505 -124.027205 1

CODE:

proc format;
value bucket 1 = "<=5"
2 ="<=10"
3 ="<=15"
4 ="<=20"
5 =">20"
;
run;


%let name=us;
filename odsout '/sasuserhome/stok';
ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm"
(title="Godwit migration")
style=sasweb;

goptions border;
goptions cback=CXFFFFFF ctext=black;
goptions xpixels=900 ypixels=600;

pattern1 value=solid color=CX60497B;
pattern2 value=solid color=CXE5E0EC;
pattern3 value=solid color=CXCCC0DA;
pattern4 value=solid color=CXB2A1C7;
pattern5 value=solid color=RED;


goptions gunit=pct htitle=6 ftitle="Calibri/Bold" htext=2.7 ftext="Calibri";
legend1 label=none shape=bar(3,1) value=(justify=left "<=5" "<=10" "<=15" "<=20" ">20" )
across=1 origin=(75,12) mode=share;
title1 lspace= 5 "Migration";



proc gmap data=birds map=mapsgfk.world all;
id long ;
choro bucket/ midpoints=1 2 3 4 5 coutline=black legend=legend1 des="First" name="FY2021" ;
run;


ODS HTML CLOSE;
ODS LISTING;

Reeza
Super User
Post your code. Your data and base map are different data sets in this case, perhaps in others they were the same?
Tommer
Obsidian | Level 7
Posted the code above. Any idea if I am doing something terribly wrong?
Reeza
Super User
Are you sure SGMAPS are not more appropriate for what you're trying to do here? They're much simpler to use if you have the latest version.
https://blogs.sas.com/content/graphicallyspeaking/2019/05/14/geocoding-us-street-addresses-and-plott...

If not, I think this is the closest example I can find to what you're trying to do and should have everything you need to follow along.
Map:
https://robslink.com/SAS/democd16/office.htm

Code:https://robslink.com/SAS/democd16/office.sas

ballardw
Super User

@Tommer wrote:
Posted the code above. Any idea if I am doing something terribly wrong?

Using LONG as an ID variable.

 

If you examine the map data set the ID variable is using a two letter country abbreviation as the ID, i.e. AD for Andorra.

So none of your Long values will match the ID in the map data set.

 

I don't know what you may have used before but with this map data set you would have to provide an ID that matches. Which means doing some Geocoding to get the the country code to add to the summary values before mapping.

Tommer
Obsidian | Level 7
Thanks ballardw, I added the ID variable in my dataset too for country code and I could generate the map. However, what I was looking for is drilling down to specific location within the country. Using country code as ID, it helps in showing the data for country but not for specific location within the country. Hence, I was using ID variable as LONG.

Is it possible to drill down to specific location within country?
ballardw
Super User

@Tommer wrote:
Thanks ballardw, I added the ID variable in my dataset too for country code and I could generate the map. However, what I was looking for is drilling down to specific location within the country. Using country code as ID, it helps in showing the data for country but not for specific location within the country. Hence, I was using ID variable as LONG.

Is it possible to drill down to specific location within country?

Specific location within an area in Gmap usually means an Annotate data set. You add some extra variables to describe what you want to appear, such as marker size and shape and/or text, along with the coordinates to place the information.

 

There are a number of examples at https://support.sas.com/sassamples/graphgallery/PROC_GMAP_Graph_Elements_Annotation.html

Example Sample 24906 shows placing city markers and names on a world map using the Maps.world map data set. Similar should be an easy transfer the the GFK version if you use the LATLON option you wouldn't need to project your coordinates.

Reeza
Super User
Or use SGMAP which is much easier for plotting point data.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 11 replies
  • 2233 views
  • 3 likes
  • 3 in conversation