BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jrrwactuary
Fluorite | Level 6

Hello Everyone,

 

I am currently trying to create a bubble plot that is gradient-filled by a specific numeric measure. Below is the code I am trying to run as well as code for a map without gradient colors for the purpose of looking at the sample data:

/*
Sample Data:
	rx_x = longitude
	rx_y = latitude
	Rx_State = state in which a pharmacy is located
	num_claims = total number of claims at a pharmacy
	sample_num = what I want to create the gradient by
	Rx_ID = ID that corresponds to a pharmacy
	Rx_Type = type of pharmacy

NOTE: the sample data consists of 4 pseudo pharmacies and do not correspond to any real data
*/
DATA sample;
	input rx_x rx_y Rx_State $ num_claims sample_num Rx_ID Rx_Type $;
CARDS;
-73.791809 40.922794 NY 600 0.87 115616 A
-73.836815 40.916695 NY 249 0.98 256156 A
-78.710464 43.170048 NY 105 0.70 615444 B
-95.300003 32.349998 TX 516 0.66 256455 B
;
RUN;


*gradient map attempt;
%let url = http://services.arcgisonline.com/arcgis/rest/services;
PROC SGMAP plotdata=sample (where=(Rx_State="NY"));
  esrimap url="&url/World_Topo_Map";
  title H=2 'Generic Sample Title';
  bubble x=rx_x y=rx_y size=num_claims / bradiusmin=1 bradiusmax=10
	colorresponse=sample_num colormodel=(yellow orange red) name='bub' transparency=0.40;
	gradlegend 'bub';
RUN;

quit;
ods html close;

*working map code;
%let url = http://services.arcgisonline.com/arcgis/rest/services;
PROC SGMAP plotdata=sample (where=(Rx_State="NY"));
  esrimap url="&url/World_Topo_Map";
  title H=2 'Generic Sample Title';
  bubble x=rx_x y=rx_y size=num_claims / bradiusmin=1 bradiusmax=10
	group=Rx_Type transparency=0.4;
RUN;

quit;
ods html close;

When I run the color gradient version of the map I get a syntax error because, according to the documentation here:

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grmapref/p1nywdk7q1c0esn1myhukeensapm.htm#p1b...

The COLORRESPONSE argument is under version SAS Viya 3.5, Post-9.4M6.

 

So I was wondering if it was possible to create a bubble map with gradient fill without the use of colorresponse, or without the use of Viya 3.5 or upgrading SAS releases?

1 ACCEPTED SOLUTION

Accepted Solutions
jrrwactuary
Fluorite | Level 6

I have been in contact with SAS support, and the solution seems to be that, instead of using gradient fill, I should use the GROUP argument in PROC SGMAP to color the bubbles by a custom group:

data cities;
  length city $20;
  input y x city $;
  state=37;
  value=rand('integer',1,50);
cards;
35.783411 -78.79892 Cary 
36.0789 -79.826888 Greensboro
35.19755 -80.834514 Charlotte
;
run;
data nc;  
  set mapsgfk.us_counties;
  where state=37;
run;
ods path(prepend) work.tempat(update);
proc template;
  define style mystyle;
    parent=styles.htmlblue;
    style graphdata1 from graphdata1 / color=cxdeebf7;
    style graphdata2 from graphdata2 / color=cx9ecae1;
    style graphdata3 from graphdata3 / color=cx3182bd;
  end;
run;
ods html style=mystyle;
proc sgmap mapdata=nc plotdata=cities;
  choromap  / mapid=id ;
  bubble x=x y=y size=value / group=value;
run;

Thank you, Marcia Surratt!

 

I did come across another potential solution that involves using PROC IML In order to utilize R's graphing functionality: https://support.sas.com/documentation/cdl/en/imlug/68150/HTML/default/viewer.htm#imlug_r_toc.htm

View solution in original post

3 REPLIES 3
ballardw
Super User

Which specific version of SAS are you running?

If you aren't sure run this code:

%put &sysvlong;

then look in the LOG and post the result. It would look something like

9.04.01M4P110916

 

It is always a good idea when asking about any error to copy the code and all the error messages from the log and paste into a text box opened on the forum with the </> icon that appears above the message window.

jrrwactuary
Fluorite | Level 6

The SAS version is in the subject line.

 

SAS Log:

NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24         
25         GOPTIONS ACCESSIBLE;
26         %let url = http://services.arcgisonline.com/arcgis/rest/services;
27         PROC SGMAP plotdata=sample (where=(Rx_State="NY"));
28           esrimap url="&url/World_Topo_Map";
SYMBOLGEN:  Macro variable URL resolves to http://services.arcgisonline.com/arcgis/rest/services
29           title H=2 'Generic Sample Title';
30           bubble x=rx_x y=rx_y size=num_claims / bradiusmin=1 bradiusmax=30
31         	colorresponse=num_claims colormodel=(yellow orange red) name='bub' transparency=0.40;
            _____________
            22
            76
ERROR 22-322: Syntax error, expecting one of the following: ;,  BRADIUSMAX, BRADIUSMIN, CM, DATALABEL, DATALABELATTRS, 
              DATALABELPOS, FILL, FILLATTRS, GROUP, IN, LEGENDLABEL, MM, NAME, NOFILL, NOMISSINGGROUP, OUTLINE, PCT, PT, PX, 
              TRANSPARENCY.  
ERROR 76-322: Syntax error, statement will be ignored.
32         	gradlegend 'bub';
33         RUN;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SGMAP used (Total process time):
      real time           0.02 seconds
      user cpu time       0.00 seconds
      system cpu time     0.03 seconds
      memory              544.37k
      OS Memory           32408.00k
      Timestamp           09/22/2021 03:53:15 PM
      Step Count                        3028  Switch Count  1
jrrwactuary
Fluorite | Level 6

I have been in contact with SAS support, and the solution seems to be that, instead of using gradient fill, I should use the GROUP argument in PROC SGMAP to color the bubbles by a custom group:

data cities;
  length city $20;
  input y x city $;
  state=37;
  value=rand('integer',1,50);
cards;
35.783411 -78.79892 Cary 
36.0789 -79.826888 Greensboro
35.19755 -80.834514 Charlotte
;
run;
data nc;  
  set mapsgfk.us_counties;
  where state=37;
run;
ods path(prepend) work.tempat(update);
proc template;
  define style mystyle;
    parent=styles.htmlblue;
    style graphdata1 from graphdata1 / color=cxdeebf7;
    style graphdata2 from graphdata2 / color=cx9ecae1;
    style graphdata3 from graphdata3 / color=cx3182bd;
  end;
run;
ods html style=mystyle;
proc sgmap mapdata=nc plotdata=cities;
  choromap  / mapid=id ;
  bubble x=x y=y size=value / group=value;
run;

Thank you, Marcia Surratt!

 

I did come across another potential solution that involves using PROC IML In order to utilize R's graphing functionality: https://support.sas.com/documentation/cdl/en/imlug/68150/HTML/default/viewer.htm#imlug_r_toc.htm

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