BookmarkSubscribeRSS Feed
GraphGuy
Meteorite | Level 14

It's really difficult to know how to help you, without knowing all the info about your custom map and the dataset you're trying to plot. This might be a problem that would be better to work directly with tech support to figure out.

 

Here is one scenario that generates the error you're seeing - a data= dataset that has no non-missing values (but I can't say whether or not your dataset has no non-missing values - this is just a wild "shot in the dark").

 

data foo;
statecode='NC'; salary=.;
run;

 

proc gmap data=foo map=mapsgfk.us;
id statecode;
choro salary;
run;

 

ERROR: No valid levels for a map.

 

pandyat0
Calcite | Level 5

Hello Robert,

 

Thank you for your feedback. I took the same approach to code and restarted the whole code from scratch and here are the results.

 

Average Total Payments.png

FILENAME op2013 "/home/pandyad0/sasuser.v94/Outpatient_CY2013.csv" TERMSTR=crlf;
PROC IMPORT DATAFILE=op2013
				OUT=WORK.op2013
				DBMS=CSV
				REPLACE;
				GETNAMES=YES;
				guessingrows=44353;
RUN;
proc contents data=op2013;
run;
data WORK.op2013V1; set WORK.op2013;
ZCTA5CE10_char=put(ZCTA5CE10,5.);
drop ZCTA5CE10;
rename ZCTA5CE10_char=ZCTA5CE10;
run;
proc MAPIMPORT datafile="/home/pandyad0/sasuser.v94/tl_2010_us_zcta510.shp" out=zshape;
run;
ods graphics on;
filename odsout '/home/pandyad0/sasuser.v94';
GOPTIONS DEVICE=png;
ODS HTML style=statistical path=odsout body="map3.html";
pattern1 v=s c=cx00ff00; 
pattern2 v=s c=cxffee00; 
pattern3 v=s c=cxffdc00;
pattern4 v=s c=cxff0000; 
proc gmap data=WORK.op2013V1 map=zshape; 
id ZCTA5CE10;
choro AverageTotalPayments / levels=4 coutline=same;
run;quit;
ODS HTML close;
ods graphics off;

By the way, data was taken from this site-- https://data.cms.gov/Medicare/Outpatient-Prospective-Payment-System-OPPS-Provide/ks44-5ax3

 

 

pandyat0
Calcite | Level 5

how do I set legend in range of values, from lowest to highest with various colors, like equal to  11 would be green. And hgihest would be red.AverageTotalPayments.png

how to separate legend with set range from 11.84 to 400.00 = green, 400 to 800 yellow and 800 to 1400 = red.

GraphGuy
Meteorite | Level 14

There are a few different ways to control the legend 'binning', but here is the one I would recommend for your situation. It gives you total control of the way the data is split into the legend bins, and how those bins are labeled.

 

First you use a data step and 'if' statements to assign each data line to a legend bin, and then you create a user-defined format to specify how you want those legend bins to be labeled. In Proc Gmap, be sure to use the 'discrete' option!

 

Here's a simple example demonstrating the technique:

 

data foo; set sashelp.us_data;
if population_2010<5000000 then legend_bin=1;
else if population_2010<=20000000 then legend_bin=2;
else if population_2010>20000000 then legend_bin=3;
run;

 

proc format;
value bin_fmt
1="<5 million"
2="5-20 million"
3=">20 million"
;
run;

 

pattern1 v=s c=lime;
pattern2 v=s c=orange;
pattern3 v=s c=red;

 

proc gmap data=foo map=maps.us all;
label legend_bin='Population:';
format legend_bin bin_fmt.;
id statecode;
choro legend_bin / discrete;
run;

 

gmap.png

 

pandyat0
Calcite | Level 5
Thank you Robert. This is indeed a very good example. I have another question about how I can fill gray color to the empty zip codes in the map above.

Thanks.
GraphGuy
Meteorite | Level 14

The answer is in 2 parts ... first, you have to use the 'all' option so that the borders of the areas with no response data actually show up in the map:

proc gmap data=WORK.op2013V1 map=zshape all;

 And then you can specify 'cdefault=gray' as a choro option after the / to make the areas with no data be filled with gray.

 

pandyat0
Calcite | Level 5

Hello Robert,

 

I am just confuse on I how can place grey color on empty zip code levels. I am still not able to figure out.

There were TWO errors: error 22-322: Syntax error

_
22
76
ERROR 22-322: Syntax error, expecting one of the following: ;, ALL, ANNOTATE, DATA, DENSITY, GOUT, LATLON, MAP, STRETCH, UNIFORM.
ERROR 76-322: Syntax error, statement will be ignored.
75 id ZCTA5CE10;
76
 
 
Here is whole copy paste page:
 
1 OPTIONS NOSYNTAXCHECK;
2 TITLE;
3 FOOTNOTE;
4 OPTIONS LOCALE=en_US DFLANG=LOCALE;
5 DATA _NULL_;
6 RUN;
 
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 767.37k
OS Memory 34988.00k
Timestamp 04/18/2017 01:24:42 AM
Step Count 164 Switch Count 22
Page Faults 0
Page Reclaims 214
Page Swaps 0
Voluntary Context Switches 33
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
 
 
7 OPTIONS VALIDVARNAME=ANY;
8 OPTIONS VALIDMEMNAME=COMPAT;
9 FILENAME _HTMLOUT TEMP;
10 FILENAME _RTFOUT TEMP ENCODING='UTF-8';
11 FILENAME _PDFOUT TEMP;
12 FILENAME _GSFNAME TEMP;
13 FILENAME _DATAOUT TEMP;
14 %LET SYSCC=0;
15 %LET _CLIENTAPP=SAS Studio;
16 %LET _CLIENTAPPVERSION=3.6;
17 %LET _SASSERVERNAME=%BQUOTE(SASApp);
18 %LET _CLIENTUSERID=%BQUOTE(pandyat0);
19 %LET _CLIENTUSERNAME=%BQUOTE(pandyat0);
20 %LET CLIENTMACHINE=%BQUOTE(134.210.198.132);
21
22 %LET _SASPROGRAMFILE = %BQUOTE(/home/pandyat0/my_content/Healthcare_Outpatient_Maps_Examples/spring2017code.sas);
23 %LET _BASEURL = %BQUOTE(https://odamid.oda.sas.com/SASStudio/);
24 %LET _EXECENV=SASStudio;
25 DATA _NULL_;
26 CALL SYMPUT("GRAPHINIT","");
27 CALL SYMPUT("GRAPHTERM","");
28 RC=TSLVL('GEOCODE','N');
29 _ERROR_=0;
30 IF (RC^=' ') THEN DO;
31 CALL SYMPUT("GRAPHINIT","GOPTIONS RESET=ALL GSFNAME=_GSFNAME;");
32 CALL SYMPUT("GRAPHTERM","GOPTIONS NOACCESSIBLE;");
33 END;
34 RUN;
 
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 787.84k
OS Memory 34988.00k
Timestamp 04/18/2017 01:24:42 AM
Step Count 165 Switch Count 58
Page Faults 0
Page Reclaims 240
Page Swaps 0
Voluntary Context Switches 161
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
 
 
35 DATA _NULL_;
36 RC=SYSPROD("PRODNUM002");
37 IF (RC^=1) THEN DO;
38 CALL SYMPUT("GRAPHINIT","");
39 CALL SYMPUT("GRAPHTERM","");
40 END;
41 RUN;
 
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 789.46k
OS Memory 34988.00k
Timestamp 04/18/2017 01:24:42 AM
Step Count 166 Switch Count 42
Page Faults 0
Page Reclaims 222
Page Swaps 0
Voluntary Context Switches 113
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
 
 
42 %LET _DATAOUT_MIME_TYPE=;
43 %LET _DATAOUT_NAME=;
44 %LET _DATAOUT_TABLE=;
45 %LET _DATAOUT_URL=;
46 %SYMDEL _DATAOUT_MIME_TYPE _DATAOUT_NAME _DATAOUT_URL _DATAOUT_TABLE;
47 %LET _SASWS_ = %BQUOTE(/home/pandyat0);
48 %LET _SASWSTEMP_=%BQUOTE(/home/pandyat0/.images/52dcdfa4-ea9f-4468-8ebe-fb31c2517d7f);
49 ODS LISTING CLOSE;
50 OPTIONS PRINTERPATH=PDF;
51 ODS AUTONAVIGATE OFF;
52 ODS GRAPHICS ON;
53 ODS HTML5 (ID=WEB) DEVICE=PNG GPATH="&_SASWSTEMP_" ENCODING=utf8 FILE=_HTMLOUT (TITLE='Results: spring2017code.sas')
53 ! STYLE=Htmlblue OPTIONS(BITMAP_MODE='INLINE' OUTLINE='ON' SVG_MODE='INLINE'
53 ! CSS_PREFIX='.ods_52dcdfa4-ea9f-4468-8ebe-fb31c2517d7f' BODY_ID='div_52dcdfa4-ea9f-4468-8ebe-fb31c2517d7f' );
NOTE: Writing HTML5(WEB) Body file: _HTMLOUT
54 ODS RTF (ID=WEB) STYLE=Rtf FILE=_RTFOUT sasdate;
NOTE: Writing RTF Body file: _RTFOUT
55 ODS PDF (ID=WEB) STYLE=Analysis FILE=_PDFOUT;
NOTE: Writing ODS PDF(WEB) output to DISK destination "_PDFOUT", printer "PDF".
56 &GRAPHINIT;
57 OPTIONS FIRSTOBS=1;
58 OPTIONS OBS=MAX;
59 OPTIONS DTRESET DATE NUMBER NOTES;
60 %put %bquote(NOTE: GOPTIONS statements in the SAS Studio environment may disable some output features.);
NOTE: GOPTIONS statements in the SAS Studio environment may disable some output features.
61 %put %bquote(NOTE: ODS statements in the SAS Studio environment may disable some output features.);
NOTE: ODS statements in the SAS Studio environment may disable some output features.
62 OPTIONS NOSYNTAXCHECK;
63
64 ods graphics on;
65 filename odsout '/home/pandyat0/sasuser.v94';
66 GOPTIONS DEVICE = png;
67 ODS HTML style = statistical path=odsout body="PlotforSpring2017AvgTotalPay.html";
NOTE: Writing HTML Body file: PlotforSpring2017AvgTotalPay.html
68 pattern1 v=s c=cx00ff00;
69 pattern2 v=s c=cxffee00;
70 pattern3 v=s c=cxffdd00;
71 pattern4 v=s c=cxff0000;
72 title 'Average Total Payments by Zip Codes';
73
74 proc gmap data=WORK.op2013V1 map=zshape all / choro cdefault=gray;
_
22
76
ERROR 22-322: Syntax error, expecting one of the following: ;, ALL, ANNOTATE, DATA, DENSITY, GOUT, LATLON, MAP, STRETCH, UNIFORM.
ERROR 76-322: Syntax error, statement will be ignored.
75 id ZCTA5CE10;
76 choro AverageTotalPayments / levels=4 coutline=same;
NOTE: The previous statement has been deleted.
77 run;
 
78 quit;
 
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE GMAP used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 3288.90k
OS Memory 43184.00k
Timestamp 04/18/2017 01:24:42 AM
Step Count 167 Switch Count 50
Page Faults 0
Page Reclaims 110
Page Swaps 0
Voluntary Context Switches 144
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 72
 
79 ODS HTML close;
80 ods graphics off;
81
82 OPTIONS NOSYNTAXCHECK;
83 ODS HTML CLOSE;
84 &GRAPHTERM; ;*';*";*/;RUN;QUIT;
85 QUIT;RUN;
86 ODS HTML5 (ID=WEB) CLOSE;
87
88 ODS RTF (ID=WEB) CLOSE;
89 ODS PDF (ID=WEB) CLOSE;
NOTE: ODS PDF(WEB) printed no output.
(This sometimes results from failing to place a RUN statement before the ODS PDF(WEB) CLOSE statement.)
90 FILENAME _GSFNAME;
NOTE: Fileref _GSFNAME has been deassigned.
 
 
91 DATA _NULL_;
92 RUN;
 
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 770.25k
OS Memory 34732.00k
Timestamp 04/18/2017 01:24:42 AM
Step Count 168 Switch Count 22
Page Faults 0
Page Reclaims 214
Page Swaps 0
Voluntary Context Switches 32
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
 
 
93 OPTIONS VALIDMEMNAME=COMPAT;
94 OPTIONS NOTES STIMER SOURCE SYNTAXCHECK;
95

 

GraphGuy
Meteorite | Level 14

Looks like there's a problem in the proc gmap line ...

 

74 proc gmap data=WORK.op2013V1 map=zshape all / choro cdefault=gray;

 

75 id ZCTA5CE10;

76 choro AverageTotalPayments / levels=4 coutline=same;

 

I think it should be more like ...

 

74 proc gmap data=WORK.op2013V1 map=zshape all;

75 id ZCTA5CE10;

76 choro AverageTotalPayments / levels=4 coutline=same;

 

 

pandyat0
Calcite | Level 5

Hello Robert,

Thank you for your answer. It worked and it looks like this:

imG1.png

Now, I have mine the data and made a subset of the data. And I wanted to make two different US states map.

In my dataset, I have AmbulatoryPaymentClassificationGroup, AverageTotalPayments, and Provider State.

I am using your example code from data foo (previously posted to show me on legend on this thread). and "http://support.sas.com/kb/41/776.html" .

 

data.png

two AmbulatoryClassificationG levels with US states. I wanted to have two US states ,map with each Levels (which are in Two levels 0209 and 0377), Do you know how I can assign PROC GMAP automatically to this data set and have the SAS make US states map with abbreviated states based on Average Total Payments values.

I am just frustrated on how I can align my data with the any example data. Any help is greatly appreciated.

Thank you.

 

 

pandyat0
Calcite | Level 5
Now I just realized that I am trying to sum the Average Total Payments values by Provider States for each AmbulatoryPaymentClassificationG.
What I have done so far is created subset for each Levels (337 nd 209). Now I just have to sum those AverageTotalPayments by states.

I am trying this. https://communities.sas.com/t5/SAS-Procedures/sums-and-counts-by-group/m-p/49057#M13309
But I do not know what is that smiley face represents.

Thanks.
-Tarak.
Reeza
Super User

@pandyat0 wrote:
Now I just realized that I am trying to sum the Average Total Payments values by Provider States for each AmbulatoryPaymentClassificationG.
What I have done so far is created subset for each Levels (337 nd 209). Now I just have to sum those AverageTotalPayments by states.

I am trying this. https://communities.sas.com/t5/SAS-Procedures/sums-and-counts-by-group/m-p/49057#M13309
But I do not know what is that smiley face represents.

Thanks.
-Tarak.

Smiley face is colon right parentheses. : + ) with no plus sign 🙂

pandyat0
Calcite | Level 5

Thanks. It worked. I also used maps.us to map the data after abbreviated the data by state. Thanks.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 26 replies
  • 2161 views
  • 0 likes
  • 4 in conversation