BookmarkSubscribeRSS Feed
JoelJ
SAS Employee

This juletip covers bought Visual Analytics 7.x and 8.x

 

Visual Analytics 7.x 

Requires SAS/GRAPH 

 

If you want to visualize your data using a map object in Visual Analytics with custom coordinates, you better hope that your longitude and latitude coordinates are in WGS84 format, or at least that was what I thought until recently. 

I found out that the dataset SASHELP.PROJ4DEF contains 7124 different coordinate definitions and that we can convert between these with the help of PROC GPROJECT. 

 

Step one, find your coordinate system 

My suggestion would be to search the DESC variable in SASHELP.PROJ4DEF (see code example below). Identify name of the target coordinate system, for WGS 84 the name is "EPSG:4326". 

 

 

proc sql; 
select *  
from SASHELP.PROJ4DEF 
where upcase(DESC) like '%SWEREF99 TM%'; 
quit; 

 

When you have found the names for the source and target coordinate systems we can move on to converting the data. In my example below there is one observation containing the coordinates for the city of Malmö in SWEREF99 TM format. 

 

 

data coordinates; 
input City $ Longitude Latitude; 
datalines; 
Malmö 373547 6163386 
; 
run; 

 

Step two, convert the data 

To do this you need to rename your longitude and latitude variables to X and Y, specify the output dataset and the names of the from and to coordinate systems. You also need to specify City as ID.

 

 

/* Convert SWEREF99 TM to WGS84 */ 
proc gproject  
data=coordinates (rename=(Longitude=X Latitude=Y))  
out= coordinates_WGS84 
project=proj4  
from="EPSG:3006" /* SWEREF99 TM */ 
to="EPSG:4326";  /* WGS 84 */ 
id City; 
run; 

 

Step three, visualize and PROFIT! 

Screen Shot 2017-12-06 at 09.28.22.png

 

 

Visual Analytics 8.x 

When you are using Visual Analytics 8.x the conversion above aren’t necessary! You create your custom geography item like you are used to do in the 7.x version but when you specify the coordinate space you choose Custom and then enter the name of the coordinate system you found in the SASHELP.PROJ4DEF table. In my case “EPSG:3006” for SWEREF99 TM. 

 Screen Shot 2017-12-06 at 09.27.32.png

 

2 REPLIES 2
AndersBergquist
Quartz | Level 8

Very good.

Please tell SAS support and Consultants about this. They have tell us there is no solution.

 

/Anders

BrunoMueller
SAS Super FREQ

hi Joel

 

Thanks for the tip, helped me find the right information for coordinates used in Switzerland. Should have have this tip a year ago;-)

 

Here are some websites with additional information:

https://epsg.io/ and http://spatialreference.org/

 

So for Switzerland I have found https://epsg.io/21781 or in GPROJECT from="EPSG:21781"

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Discussion stats
  • 2 replies
  • 2270 views
  • 19 likes
  • 3 in conversation