Data visualization with SAS programming

Proc GMAp

Reply
Occasional Contributor
Posts: 10

Proc GMAp

Help!! SAS GMAP

 

Here's the code: 

 

 

proc gproject data = work.Meteorite_Landings NORANGECHECK;
id x y;
run;

proc gmap map = maps.world data = work.Meteorite_Landings;
id x y;
run;
quit;

PROC GMAP map=maps.world data=maps.world all;
id x y;
RUN;
QUIT;

 

 

Here's the error: 

NOTE: PARALLEL1 = -78.7750025.
NOTE: PARALLEL2 = 90.0083325.
ERROR: PARALLEL2 is out of range. It's absolute value must be in [0,90]

 

 

I'm trying to create a SAS MAP similar to drillhover. I'm working on a SAS Final project for High School. All I have is coordinates of latitude and longitude. I have converted them to radians in my data set and renamed them x and y.

 

Anyone willing to help me? 

 

 

We do have the full version of SAS.

 

Grand Advisor
Posts: 10,210

Re: Proc GMAp

Is your input data for gproject in radians or degrees? If degrees you need to use the DEGREES option.

It is a good idea to provide an out=dataset explicitly, otherwise GPROJECT will create a dataset named DATAn where n is assigned numerically by the SAS system. So you didn't use the actual projected data.

Occasional Contributor
Posts: 10

Re: Proc GMAp

Initially in my dataset I had done the calculation for degrees to raidans. And since I have posted this I have added the out =.

 

Now I have this error:

 

ERROR: Variable RECLAT not found.
ERROR: Variable RECLONG not found.

 

Both reclat and reclong are the names of my latitude and longitude in my data set. 

 

This is what I have so far: 

 

proc gproject data = work.Meteorite_Landings norangecheck degree out = work.gproject;
id Reclat Reclong;
run;

proc gmap map = maps.world data = work.gproject;
id Reclat Reclong;
run;

 

 

I'm not sure if I'm doing this ID thing right as I have never used proc gmap or gproject in my class at school.

Grand Advisor
Posts: 17,333

Re: Proc GMAp

ID would be to identify groups of spatial information, for example State may be an ID variable. So I don't think lat/long variables belong in ID.

Not found is a different error though, your code is missing something, somewhere. Can you post the full code.


Occasional Contributor
Posts: 10

Re: Proc GMAp

[ Edited ]

My code I guess isn't the best but it does what I want it so far

 

Full code:

 

data work.Meteorite_Landings;

infile 'H:\SAS\Final Project\Meteorite_Landings.csv' dlm = ',' missover dsd;

length Name $ 25
Nametype $ 6
Recclass $ 15
Fall $ 6
Date $ 20
GeoLocation $ 30;

input Name $
ID
Nametype $
Recclass $
MassGrams
Fall $
Date $
Reclat
Reclong
GeoLocation $;

/* Drop latitude and longitude
drop Reclat
Reclong; */


if Name ne 'name';


if (Name = ' ') or (ID = '.') or (Nametype = ' ') or (Recclass = ' ') or (MassGrams = '.') or (Fall = ' ') or (Date = ' ') or (Reclat = '.') or (Reclong = '.') or (GeoLocation = ' ') then delete;


if (length(GeoLocation) > 30) or (length(GeoLocation) < 6) or (index(GeoLocation,'"')) or (length(Date) < 6) or (length(Fall) > 8) or (length(Fall) > 10) then delete;


Year = substr(scan(Date,1,' '),7,4);

Fall = tranwrd(Fall,'ound','Found');
Fall = tranwrd(Fall,'FFound','Found');


label Name = 'Meteorite*Name'
ID = 'ID #'
Nametype ='Name Type'
Recclass = 'Classification'
MassGrams = 'Mass in*Grams'
Fall = 'Fall'
GeoLocation = 'Geographic*Location'
Year = 'Year Fell';

format MassGrams comma14.2;
run;

proc gproject data = work.Meteorite_Landings norangecheck degree out = work.gproject;
id Reclat Reclong;
run;

proc gmap map = maps.world data = work.gproject;
id Reclat Reclong;
run;
quit;

 

 

Occasional Contributor
Posts: 10

Re: Proc GMAp

Please, anyone still out there willing to help me? I'm running out of time.

Grand Advisor
Posts: 10,210

Re: Proc GMAp

The variables to be projected must be named X and Y. AND X and Y do NOT go on an ID statement. Those variables should identification information such as country name, or meteor strike label or such.

SAS Employee
Posts: 170

Re: Proc GMAp

Perhaps this example would be better:  http://support.sas.com/rnd/papers/#SGF2009.    Tips and Tricks IV: More SAS/GRAPH Map Secrets

 

In your program, you have to:  1. Set x and y from reclong and reclat in Meteorite_landing.  I would also set a flag called "annoflag" to be used later.  2.  set the MAPSGFK.WORLD to Work.WORLD and set X to LONG and Y to LAT.  3. Set the REDUCE value when you do that so it isn't so large.  4. Combine WORLD and METEORITE_LANDING into one data set (COMBINED); GPROJECT combined; then split it back into 2 data sets (using ANNOFLAG).  5.  ANNOTATE the points in METEORITE_LANDING.  6.  On GMAP, make DATA and MAP the same and added ANNO=.

 

I thing this example will show you how to do everything.  There is too much for me to explain everything.

 

SAS Employee
Posts: 170

Re: Proc GMAp

Oh, the example is named:  sasu1

SAS Employee
Posts: 967

Re: Proc GMAp

Joel - I'm glad to see you're using SAS. Hopefully you'll find comfort when I tell you that you've jumped right into one of the most difficult graphics areas. When it comes to working with maps, and lat/long data, there are several things you have to understand, and keep straight, such as ... coordinates in degrees or radians, your map area id variables, eastlong or westlong coordinate system (foryour map, and your data), map projections, annotate coordinate system, etc. There is no cut-and-dry answer that solves all map problems though.

 

This mapping chapter will help you with some of those things (but it's written for someone who already has an intermediate knowledge of mapping in SAS)...

 

   http://robslink.com/SAS/book2/Chapter_07_Annotating_on_Maps.pdf

 

Being that this is a school project, I hate to hand over a complete solution ... but I do happen to have a complete solution in-hand for plotting meteorite impacts on a map in SAS. If you choose to use this to help you along with your map, be sure to let your teacher know what you know/understand on your own, and what (if any) you use from my example:

 

http://robslink.com/SAS/democd28/impact.htm

http://robslink.com/SAS/democd28/impact_info.htm  (<- SAS code link is in here)

 

Below is a snapshot of the map (the impact.htm link above is the interactive version, with drilldowns):

 

impact.png

 

Occasional Contributor
Posts: 10

Re: Proc GMAp

Hello, thank you. Don't worry my project isn't  solely based around this map.

 

A few questions for you:

1. Where's antarctica a lot of my data is based from there (not all but most) ??

2. What are the exact steps of making this map? 

  • I have my data set/step "Meteorite_Landings"
  • What other data set do I need to make? I'm sorry I'm new to all this proc gmap but what/why do I need to combine?
  • I have a proc gproject with out =
  • I have a proc gmap

 

3. What is anno_flag?

 

SAS Employee
Posts: 967

Re: Proc GMAp

#1.

 

Antarctica is intentionally excluded from the map by this code:

 

/* Reduce the size of the world map, and get rid of some of the islands */
/* leave out antarctica */
data world (rename=(long=x lat=y cont=continent id=country));
 set maps.world (where=( (density<=1) and (id ^= 143) ) drop = x y);
long=long*-1;
run;'

 

I find that when I leave Antarctica in the world map, it gets stretched so far out of proportion (with most projections) that it is not useful. Instead, when I want to show lat/long locations there, I generally create a map of just that continent. Here's an example:

 

http://robslink.com/SAS/democd21/antarc.htm

http://robslink.com/SAS/democd21/antarc_info.htm

 

antarc.png

 

#2.

 

The exact steps are all in the SAS code (see earlier link). And the process is also described in great detail in other examples in the book chapter I posted (see earlier link). Each map will use slightly different code, but generally the same process.

 

#3.

 

Anno_flag is a variable I add to the annotate dataset. This allows me to combine the annotate dataset and the map dataset, gproject them together (so things will line up properly), and then separate them again (so they can be used as map, and annotate, datasets).

 

Occasional Contributor
Posts: 10

Re: Proc GMAp

Wow, thanks for the help! This is way more complicated than I originally thought and really don't know how to do this on my own. Is there any part of code in the example I do not need? 

 

Is there any way that can do this to a level that isn't as complicated and easy for me to figure out or..??

 

Occasional Contributor
Posts: 10

Re: Proc GMAp

Hey guys,

 

First of all, I'd really like to thank you for helping me thus far; I realize you may be worried about me cheating on a project, but this is all completely optional and doesn't affect my grade --- it's a matter of aesthetics.

 

Since my knowledge of SAS is limited, I was hoping I could reiterate what I know, what I have so far, and what exactly is in my data set. From there, I would be honored if you guys could help me from what I have.

 

I am trying to create a map of the world with coordinates as simple dots. I realize that you guys have already given me numerous different examples, but like I stated previously, my knowledge of SAS is limited and I really have no idea what's going on in any of them.

 

I've attached the code I have thus for the map (its in a text file, as the forums aren't letting me submit a .sas file).

SAS Employee
Posts: 170

Re: Proc GMAp

You are close.

 

In the meteorite_landings data step, you need to:

   1.  Convert reclong and reclat to radians in X and Y.

   2.  Added some more annotate code.

x= reclong*atan(1)/45;

y= reclat*atan(1)/45;

function="pie"; style="psolid"; rotate=360; size=0.2; color='red';

 

You need to change MAPS.WORLD into WORLD and x=-long; y=lat; to be using unprojected values.

You are doing this since you are not using GPROJECT. 

 

In gmap, you need to use WORLD instead of MAPS.WORLD.  And you need to use ID id; choro id;

 

Ask a Question
Discussion stats
  • 14 replies
  • 972 views
  • 0 likes
  • 5 in conversation