BookmarkSubscribeRSS Feed
joel94657534034
Calcite | Level 5

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.

 

14 REPLIES 14
ballardw
Super User

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.

joel94657534034
Calcite | Level 5

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.

Reeza
Super User
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.


joel94657534034
Calcite | Level 5

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) > 😎 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;

 

 

joel94657534034
Calcite | Level 5

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

ballardw
Super User

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.

Darrell_sas
SAS Employee

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.

 

Darrell_sas
SAS Employee

Oh, the example is named:  sasu1

GraphGuy
Meteorite | Level 14

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

 

joel94657534034
Calcite | Level 5

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?

 

GraphGuy
Meteorite | Level 14

#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).

 

joel94657534034
Calcite | Level 5

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..??

 

joel94657534034
Calcite | Level 5

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).

Darrell_sas
SAS Employee

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;

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 14 replies
  • 2833 views
  • 0 likes
  • 5 in conversation