Data visualization with SAS programming

proc gmap

Reply
Contributor
Posts: 47

proc gmap

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
SAS Employee
Posts: 980

Re: proc gmap

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;
Contributor
Posts: 47

Re: proc gmap

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
SAS Employee
Posts: 170

Re: proc gmap

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.
SAS Employee
Posts: 980

Re: proc gmap

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
Ask a Question
Discussion stats
  • 4 replies
  • 230 views
  • 0 likes
  • 3 in conversation