Hi all.
I have been searching for a bit now trying to find a solution to my current issue. I am trying to project latitude and longitude onto a specific map in the MAPSGFK folder using PROC SGMAPS SCATTER.
I realize that the lat/lon need to be converted. I have tried converting using PROC GPROJECT, but the points don't line up on the maps, specifically on MAPSGFK.us (I'm using sashelp.springs for my scatter data). You can see Alaska, HI, and the lower 48 states outlined by the dots:
So for my question, is there a command/function to convert lat/lon specifically by map, or do I need to do some extra work to get it to fit correctly?
Here is my code for reference:
data springs (rename=(latitude=y longitude=x));
set sashelp.springs;
run;
proc gproject data=springs out=springs_proj degrees eastlong; /*not sure of these options*/
id type;
run;
proc sgmap mapdata=mapsgfk.us plotdata=springs_proj;
choromap / mapid=state;
scatter x=x y=y / markerattrs=(color=blue size=2 symbol=circlefilled);
run;
Apologies if this has been answered over and over... I haven't been able to find the right answer.
Thanks!
SA
It sounds like you're asking 2 questions here:
So, for #1, yes there is. You can use the PARMIN= option to PROC GPROJECT to project for any map in the MAPSGFK library except for the one you're trying to use. That get's me to #2, which the answer is "no". The US map you show has specially-processed data to bring in AK and HI from their normal locations. Furthermore, different projections were used on them, and they were scaled. So there is no single command to project to that map.
For the other maps that you can use the PARMIN= option, you simply specify the name of the dataset you'd like it to be projected for. They're all located in the MAPSGFK.PROJPARM data set.
Hope this helps, and happy mapping!
Jeff Phillips
SAS
As Jeff says, Alaska & Hawaii have been moved/projected/scaled differently from the rest of the US, in this particular map (mapsgfk.us). Therefore, there is no one/simple command that will move/project/scale arbitrary lat/long coordinates and have them line up with the map.
But ... mapsgfk.uscity has applied the same move/project/scale to all the mapsgfk.uscity locations, so they line up with mapsgfk.us ... and therefore if you find the closest city to each of your lat/long locations, you could look up the x/y from mapsgfk.uscity, and plot those locations on the map. Here's a small example showing all the mapsgfk.uscity locations overlaid on mapsgfk.us:
title "mapsgfk.us with mapsgfk.uscity locations overlaid";
proc sgmap mapdata=mapsgfk.us noautolegend plotdata=mapsgfk.uscity;
choromap / mapid=statecode;
scatter x=x y=y / markerattrs=(size=1px color=red symbol=circlefilled) transparency=0;
run;
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.