BookmarkSubscribeRSS Feed
SachinRuk
Calcite | Level 5
Hi All,

Im trying to map some data on to the australian map (called austral i believe).

Say the data is as follows:
lat long expenditure
-31.5 149.8 $5000
-30.5 148.2 $3000
-29.6 147.3 $7000

How do I plot the above data onto the australian map? Is using Gproject an absolute must?

Thanks,
Sachin
4 REPLIES 4
GraphGuy
Meteorite | Level 14
yes - using Proc Gproject is an absolute must, to get lat/long data to line up in the correct location on a map.

The following code should get you started:

data foo;
input lat long expenditure;
datalines;
-31.5 149.8 5000
-30.5 148.2 3000
-29.6 147.3 7000
;
run;


data foo; set foo;
/* convert degrees to radians, and longitude to 'eastlong' */
x=atan(1)/45 * long * -1;
y=atan(1)/45 * lat;
anno_flag=2;
run;

/* combine and project the lat/long radian values */
data combined; set maps.austral (drop = x y rename=(lat=y long=x)) foo;
run;
proc gproject data=combined out=combined dupok;
id id;
run;

/* separate the map and point data again */
data austral foo; set combined;
if anno_flag eq 2 then output foo;
else output austral;
run;

/* convert projected point data into annotated text */
data foo; set foo;
length color $8 text $50;
xsys='2'; ysys='2'; hsys='3'; when='a';
function='label'; size=2;
color='red';
text=put(expenditure,dollar10.0);
run;

pattern1 v=solid color=cornsilk;
title "Australia Expenditures";
proc gmap map=austral data=austral anno=foo;
id id;
choro id / levels=1 nolegend coutline=grayaa;
run;
SachinRuk
Calcite | Level 5
Thanks Rob,

That helped heaps.

Any suggestions as to how to use a heat map on this (or atleast a traffic light one) such that I get a red dot for the $7000, amber for $5000 and so on.

Cheers,
Sachin
Darrell_sas
SAS Employee
Just modify the code where you create the annotate dataset.
Where it currently says:
color='red';

Add some logic like this:
if (expenditure >= 7000) then color='red';
else if (expenditure < 7000 and expenditure >= 5000) then color='orange';
else color='green';

Tweak it according to your needs.
GraphGuy
Meteorite | Level 14
To see some sample code for annotating colored dots on Australia, see the following thread from last month:

http://support.sas.com/forums/thread.jspa?messageID=49103

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 4 replies
  • 865 views
  • 0 likes
  • 3 in conversation