Hi,
I want to show markers on a map using the PROC GMAP statement (following this example). However, I think my map data uses a different type of data compared to my marker data.
How can I manipulate my data so that I can show markers on my map? I have tried the code below unsuccesfully.
Thanks in advance for any help.
The code
proc gproject data=marker_data out=marker_data eastlong latlong degrees;
id pc4nr;
run;
My Netherlands map data uses the following XY coordinates
X Y
122146.69994 487964.19995
122192.39992 487945.20011
122265.2 487932.00006
122301.70003 487966.79998
122515.99996 487935.89999
122534.30007 487892.70001
My marker_data uses LATLONG codes
lat long
52.1392 5.0417
52.1392 5.0417
52.025 4.8681
52.025 4.8681
52.1392 5.0417
My marker_data after GJPROJECT
X Y
-0.005838858 -0.005235953
-0.005838858 -0.005235953
-0.007718145 -0.007212797
-0.007718145 -0.007212797
-0.005838858 -0.005235953
Looks like the X & Y in your map dataset is already projected, or in a different coordinate system.
You'll need to find out what projection/coordinate-system was used for the map, and then either "unproject" the map X/Y's to get them into lat/long coordinates (same as your marker data), or project your marker data the same way. (Modern versions of Proc Gproject have a from= and to= option that can help in converting). I usually get both the map and marker data into lat/long, and then project them both, using a projection before plotting them together.
When you tried projecting your marker data, it just used SAS' "default projection" ... which is not the same projection that was used to project your map.
My Netherlands map data uses the following XY coordinates
X Y
122146.69994 487964.19995
What do these numbers represent? In order to translate, you need a translation rule.
Do you have a couple of points in both coordinate systems?
Hi Chris,
Thanks for the quick reply.
Those numbers represent some type of coordinates per Dutch zipcode (4 digits). The map data is a set we had lying around at the office.
For zipcode 1011 and 1012, my map data contains:
X | Y | PC4NR |
122146.69994 | 487964.19995 | 1011 |
122192.39992 | 487945.20011 | 1011 |
122265.2 | 487932.00006 | 1011 |
122301.70003 | 487966.79998 | 1011 |
122515.99996 | 487935.89999 | 1011 |
122534.30007 | 487892.70001 | 1011 |
122604.19995 | 487881.30011 | 1011 |
122623.79997 | 487682.30003 | 1011 |
122691.20003 | 487652.59997 | 1011 |
122762.20003 | 487253.29992 | 1011 |
122673.80005 | 487088.69993 | 1011 |
122249.49991 | 486641.70001 | 1011 |
121923.30006 | 486531.90005 | 1011 |
121837.09992 | 486639.69995 | 1011 |
121722.79996 | 486711.80009 | 1011 |
121524.39992 | 486751.09991 | 1011 |
121899.8999 | 487422.09993 | 1011 |
121940.80003 | 487820.99993 | 1011 |
122079.60006 | 487836.99992 | 1011 |
122146.69994 | 487964.19995 | 1011 |
121409.6 | 488033.1001 | 1012 |
121608.89998 | 488308.29993 | 1012 |
121624.40009 | 488294.20004 | 1012 |
121759.2 | 488197.30003 | 1012 |
122114.40001 | 487977.59992 | 1012 |
122146.69994 | 487964.19995 | 1012 |
122079.60006 | 487836.99992 | 1012 |
121940.80003 | 487820.99993 | 1012 |
121899.8999 | 487422.09993 | 1012 |
121524.39992 | 486751.09991 | 1012 |
121313 | 486706.00007 | 1012 |
121123.29994 | 486701.70009 | 1012 |
121010.60007 | 486854.39992 | 1012 |
120995.59993 | 486931.2001 | 1012 |
121098.4001 | 487516.5001 | 1012 |
121409.6 | 488033.1001 | 1012 |
My zipcode coordinate data set contains the following data for that same zipcode:
Longitude | Latitude | Postal Code |
49.027 | 523.666 | 1011 |
49.027 | 523.666 | 1012 |
1. Both zip codes at the same location?
2. So many X Y to one LAT LON?
I'm getting lost here. Can you give more context?
You might need to use the centroids (which can be approximated using the averages for now) then.
1011:
122231.7799825 | 487475.77499 |
1012:
121566.149998125 | 487584.3000025 |
3. Why not use the SAS/GRAPH NL map?
Answers:
1. They are the same zipcode so they should represent the same location.
2. I'm unsure why there are so many XY values per zipcode. The data set was already present, but the person who created that dataset is no longer working here. I found the zipcode LATLON data online. It did not contain any further documentation.
3. I could use the SAS MAP if there's a way to create zipcode boundaries. The NL map only contains province boundaries. The data I have is zipcode based. I need to create that countains specific boundaries (administrative regions for Dutch longterm healthcare based on zipcodes). The map data we have does contain does those boundaries.
Questions:
A. In your second answer you mention using centroids. Would it be an option to use my current map data to create centroids per zipcode, geocode those centroids to my zipcode data set and then plot those on my map?
How are zip code 1011 and zip code 1012 the same?
This website disagrees http://www.geonames.org/postalcode-search.html?q=1011&country=NL
What happens when you run
proc gmap data=NLMAP(keep=X Y PC4NR) map=NLMAP; id PC4NR; choro X ; run; quit;
Hi Chris,
I'm sorry for the misunderstanding. Zipcode 1011 and 1012 are not the same. I thought you meant the same for both my data sets. I included two observations, to make it more clear.
Last night (I could not let this rest) I had a breakthrough. It turns out my map data uses a Dutch system, known as the National Triangular System (Rijksdriehoekstelsel or EPSG:28992). It uses meters from a random zero point and allows all of Western Europe to have positive values so that there's no misunderstanding about left or right. The Dutch Navi provided a program to translate that system to latitude and longitude data, so I'll try to run that.
I think this solves my problem for now. I like the boundaries of the SAS map more than I like those of my zip code data (water also has a zipcode), but that is a different question.
Thanks for all your time and effort in solving this problem.
PS running your code gave me the attached result.
Looks like the X & Y in your map dataset is already projected, or in a different coordinate system.
You'll need to find out what projection/coordinate-system was used for the map, and then either "unproject" the map X/Y's to get them into lat/long coordinates (same as your marker data), or project your marker data the same way. (Modern versions of Proc Gproject have a from= and to= option that can help in converting). I usually get both the map and marker data into lat/long, and then project them both, using a projection before plotting them together.
When you tried projecting your marker data, it just used SAS' "default projection" ... which is not the same projection that was used to project your map.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.