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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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