BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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;

Ksharp_0-1712382944999.png

 

View solution in original post

2 REPLIES 2
ballardw
Super User

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.

 

Ksharp
Super User

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;

Ksharp_0-1712382944999.png

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 291 views
  • 0 likes
  • 3 in conversation