Hello,
Using SAS 9.4. I have a dataset with zip code and ADI available. I am using the code below to map the location of each zip code and I would like to create a map that has a flag instead of bubble but in an ideal world I would also color code the flag based on ADI(a score from 0-100) and have the size of the flag representative of the frequency of that location. For instance, zip code 24293 has 2 observations, so I would like this flag to be larger as there are 2 of them versus other zip codes with only 1 observation. I have been using the documentation from this website (chrome-extension://efaidnbmnnnibpcajpcglclefindmkaj/https://support.sas.com/resources/papers/proceedings19/3314-2019.pdf) but I am not sure where to proceed. Any guidance is helpful. Thank you
data locations;
input zip national_Adi;
datalines;
28025 62
28216 72
28208 87
72173 66
23072 42
27520 49
27587 29
23321 30
20905 10
27504 56
22572 62
72761 56
66223 24
78664 14
24354 70
24293 85
24293 85
23970 64
;
proc geocode data=locations out=locations2
method=zip
attribute_var=(national_Adi);
run;quit;
proc sgmap plotdata=locations2 maprespdata=locations2;
openstreetmap;
scatter x=x y=y / markerattrs=(size=10) datalabel=national_ADI datalabelattrs=(size=4);
run;
You could use BUBBLE statement instead of SCATTER.
data locations;
input zip national_Adi;
datalines;
28025 62
28216 72
28208 87
72173 66
23072 42
27520 49
27587 29
23321 30
20905 10
27504 56
22572 62
72761 56
66223 24
78664 14
24354 70
24293 85
24293 85
23970 64
;
proc geocode data=locations out=locations2
method=zip
attribute_var=(national_Adi);
run;quit;
proc freq data=locations noprint;
table zip*national_Adi/out=_count;
run;
proc sort data=locations2;by zip national_Adi;run;
data locations3;
merge locations2 _count;
by zip national_Adi ;
run;
proc sgmap plotdata=locations3 maprespdata=locations3;
openstreetmap;
bubble x=x y=y size=count/ datalabel=national_ADI datalabelattrs=(size=4);
run;
Since you want to change a symbol based on the count of something I would suggest summarizing your data to get that count as variable. Then you could change the size based on that value.
With a non-standard symbol, such as "flag" I would suggest finding a unicode character of a basic flag and then using one of the example text plots using unicode as appear on https://blogs.sas.com/content/graphicallyspeaking/2021/10/22/how-to-mislabel-a-map/
The SGMAP Text statement will allow using a COLORRESPONSE statement to use the value of a variable to change the color. The COLORMODEL will work with that variable to assign specific color ranges.
You could use BUBBLE statement instead of SCATTER.
data locations;
input zip national_Adi;
datalines;
28025 62
28216 72
28208 87
72173 66
23072 42
27520 49
27587 29
23321 30
20905 10
27504 56
22572 62
72761 56
66223 24
78664 14
24354 70
24293 85
24293 85
23970 64
;
proc geocode data=locations out=locations2
method=zip
attribute_var=(national_Adi);
run;quit;
proc freq data=locations noprint;
table zip*national_Adi/out=_count;
run;
proc sort data=locations2;by zip national_Adi;run;
data locations3;
merge locations2 _count;
by zip national_Adi ;
run;
proc sgmap plotdata=locations3 maprespdata=locations3;
openstreetmap;
bubble x=x y=y size=count/ datalabel=national_ADI datalabelattrs=(size=4);
run;
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.