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!
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.
Very good.
Please tell SAS support and Consultants about this. They have tell us there is no solution.
/Anders
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"
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.