BookmarkSubscribeRSS Feed
pandyat0
Calcite | Level 5

Hello,

I am working with health data file which I would like to make a choropleth map and map all locations which are on file on a US map?

And run analysis of which hospital (most expensive and least) and also which state/city has most outpatient for ambulatory cause? 

the data file looks like below.

 

APCG,ProvId,ProvName,ProvStrAd,ProvCity,ProvSt,ProvZipC,ProvHRR,OPServs,AvgEstSubChrg,AvgTotPay
0013-LevelIIDebridement&Destruction,10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,639,$391.64,$54.94
0015-LevelIIIDebridement&Destruction,10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,503,$595.82,$83.51
0019-LevelIExcision/Biopsy,10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,23,$3531.88,$254.15
0020-LevelIIExcision/Biopsy,10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,32,$4596.94,$507.30
0078-LevelIIIPulmonaryTreatment,10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,142,$218.82,$87.60
0096-LevelIINoninvasivePhysiologicStudies,10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,363,$988.04,$93.59
0204-LevelINerveInjections,10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,385,$2084.46,$147.57
0206-LevelIINerveInjections,10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,67,$1438.85,$240.75
0207-LevelIIINerveInjections,10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,3169,$2228.79,$480.49
"0209-LevelIIExtendedEEG,Sleep,andCardiovascularStudies",10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,729,$4468.12,$697.15
0265-LevelIDiagnosticandScreeningUltrasound,10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,279,$805.98,$56.25
0267-LevelIIIDiagnosticandScreeningUltrasound,10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,1737,$858.17,$134.91
0269-LevelIIEchocardiogramWithoutContrast,10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,844,$2024.28,$339.31
0270-LevelIIIEchocardiogramWithoutContrast,10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,40,$2968.67,$486.59
0336-MagneticResonanceImagingandMagneticResonanceAngiographywithoutContrast,10001,SOUTHEASTALABAMAMEDICALCENTER,1108ROSSCLARKCIRCLE,DOTHAN,AL,36301,AL-Dothan,1656,$3729.89,$300.47

Thanks in advance. 

26 REPLIES 26
Reeza
Super User

Please see sample maps at http://robslink.com/SAS/Home.htm

 

His maps include code samples as well. You'll need to map your locations to latitude and longitude. If you have the addresses look at proc geocode. 

Darrell_sas
SAS Employee

I am not sure what you want to do.  Do you want a Choro map with each State or County colored for all the Hospitals in the region?  Or do you want a point map with a point for each hospital?  I notice that you have multiple records for a hospital.  If you draw a point for each one, only one point will show up on your map for that hospital.  You can draw a Dot-Density map where it scatters the points around for a hospital so you can see a bunch of points.  Below are examples of all three maps.  These are on the webpage http://support.sas.com/rnd/papers/#SGF2011 under the paper title Outbreak Maps: Visually Discovering Your Data.  There is a link to the examples.

 

Choro map, Point map and Dot Density map:

Choro.PNG

point.PNG

DotDensity.PNG

pandyat0
Calcite | Level 5

Hello Darrell,

 

Thank you so much. This site is definetely very useful in visulazing maps in sas. Like you suggested, I want a point map with a point for each hospital. So when I draw a point for each one, I want each point to show up on my map for that hospital. So I think drawing a Dot-Density map where it scatters the points around for a hospital is exactly what I was looking for. This is great example with downloadable zip folder. I also would like to make a dot density map of each hospital according to Price (gradients of different colors based on prices). I will post whatever I get here. If you have any suggestions related on which columns I could use to do cost analyitcs please feel free to provide that information. Thank you. 

 

 

pandyat0
Calcite | Level 5
FILENAME op2013"/home/pandyat0/sasuser.v94/Outpatient_CY2013.csv" TERMSTR=LF;
/** Import the CSV file. **/
PROC IMPORT DATAFILE=op2013
OUT=WORK.op2013
DBMS=CSV
REPLACE;
GETNAMES=Yes;
guessingrows=44353;
RUN;
/*Detailed Contents of Outpatient 2013 datafile*/
proc contents data=op2013;
run;

/* MAPPING CODE STARTS BELOW: */
/*Use Mapimport to grab shapefile from zipcode folder under Files-->my_content-->zipcode
* Mapimport will import boundary file*/
proc MAPIMPORT
datafile="/home/pandyat0/my_content/zipcode/tl_2010_us_zcta510.shp"
out=WORK.zshape;
run;

/*Import Ambulatory data columns (prices)*/
*data op2013; length ProviderZipCode $5.;
*out=op2013part2;
* set op2013part2;
*out=op2013part2;
*ProviderZipCode=left(geoid);
*if state='VA';
*run;
/* Map the Data*/
ods graphics on;
ODS HTML style=statistical;
goptions ftitle='Arial';
title1 " "; title10 h=2.2 "Ambulatory Payments Classification System by Avg. Total Payments "; footnote " ";
/* colors from green->red */
pattern1 v=s c=cx00ff00; pattern2 v=s c=cx35ff00; pattern3 v=s c=cx65ff00;
pattern4 v=s c=cx88ff00; pattern5 v=s c=cx9aff00; pattern6 v=s c=cxbaff00;
pattern7 v=s c=cxccff00; pattern8 v=s c=cxd0ff00; pattern9 v=s c=cxe0ff00;
pattern10 v=s c=cxffff00; pattern11 v=s c=cxffee00; pattern12 v=s c=cxffe000;
pattern13 v=s c=cxffdd00; pattern14 v=s c=cxffdc00; pattern15 v=s c=cxffd800;
pattern16 v=s c=cxffd100; pattern17 v=s c=cxffcd00; pattern18 v=s c=cxffc000;
pattern19 v=s c=cxffb700; pattern20 v=s c=cxff9a00; pattern21 v=s c=cxff8700;
pattern22 v=s c=cxff7700; pattern23 v=s c=cxff5400; pattern24 v=s c=cxff3400;
pattern25 v=s c=cxff0000;

/*map the data from ambulatory data with shapefile as choropleth map*/
proc gmap data=op2013 map=WORK.zshape;
id ProviderZipCode; /* matches values between response and map dataset */
choro AverageTotalPayments /* response variable */
/ levels=25 /* pattern/color levels */
nolegend coutline=same /* turn off boundary lines*/;
run;quit;
ODS HTML close;
ods graphics off;
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
/*Map of US with states*/
proc gmap
map=maps.us
data=maps.us (obs=1)
all;
id state;
choro state / nolegend;
run;
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
I am getting an error no HTML which is below:

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
NOTE: GOPTIONS statements in the SAS Studio environment may disable some output features.
NOTE: ODS statements in the SAS Studio environment may disable some output features.
57
58 ods graphics on;
59 ODS HTML style=statistical;
NOTE: Writing HTML Body file: sashtml10.htm
ERROR: Insufficient authorization to access /pbr/biconfig/940/Lev1/SASApp/sashtml10.htm.
ERROR: No body file. HTML output will not be created.
60 goptions ftitle='Arial';
61 title1 " "; title10 h=2.2 "Ambulatory Payments Classification System by Avg. Total Payments "; footnote " ";
62 /* colors from green->red */
63 pattern1 v=s c=cx00ff00; pattern2 v=s c=cx35ff00; pattern3 v=s c=cx65ff00;
64 pattern4 v=s c=cx88ff00; pattern5 v=s c=cx9aff00; pattern6 v=s c=cxbaff00;
65 pattern7 v=s c=cxccff00; pattern8 v=s c=cxd0ff00; pattern9 v=s c=cxe0ff00;
66 pattern10 v=s c=cxffff00; pattern11 v=s c=cxffee00; pattern12 v=s c=cxffe000;
67 pattern13 v=s c=cxffdd00; pattern14 v=s c=cxffdc00; pattern15 v=s c=cxffd800;
68 pattern16 v=s c=cxffd100; pattern17 v=s c=cxffcd00; pattern18 v=s c=cxffc000;
69 pattern19 v=s c=cxffb700; pattern20 v=s c=cxff9a00; pattern21 v=s c=cxff8700;
70 pattern22 v=s c=cxff7700; pattern23 v=s c=cxff5400; pattern24 v=s c=cxff3400;
71 pattern25 v=s c=cxff0000;
72
73 /*map the data from ambulatory data with shapefile as choropleth map*/
74 proc gmap data=op2013 map=WORK.zshape;
75 id ProviderZipCode; /* matches values between response and map dataset */
76 choro AverageTotalPayments /* response variable */
77 / levels=25 /* pattern/color levels */
78 nolegend coutline=same /* turn off boundary lines*/;
79 run;

ERROR: ID variable ProviderZipCode is not found in MAP data set.
79 ! quit;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE GMAP used (Total process time):
real time 0.10 seconds
user cpu time 0.02 seconds
system cpu time 0.01 seconds
memory 5793.93k
OS Memory 36524.00k
Timestamp 11/17/2016 04:54:17 AM
Step Count 48 Switch Count 48
Page Faults 3
Page Reclaims 441
Page Swaps 0
Voluntary Context Switches 144
Involuntary Context Switches 0
Block Input Operations 1528
Block Output Operations 56

80 ODS HTML close;
81 ods graphics off;
82 /*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
83 /*Map of US with states*/
84 proc gmap
85 map=maps.us
86 data=maps.us (obs=1)
87 all;
88 id state;
89 choro state / nolegend;
90 run;
91
92
93 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
105


My question would be do I need same Zipcode length (my file have 8 and the shape code file is 5 ) Look at 7 (last row).

Alphabetic List of Variables and Attributes
# Variable Type Len Format Informat
1 AmbulatoryPaymentClassificationG Char 85 $85. $85.
10 AverageEstimatedSubmittedCharges Num 8 NLNUM12. NLNUM32.
11 AverageTotalPayments Num 8 NLNUM12. NLNUM32.
9 OutpatientServices Num 8 BEST12. BEST32.
5 ProviderCity Char 15 $15. $15.
8 ProviderHRR Char 26 $26. $26.
2 ProviderId Num 8 BEST12. BEST32.
3 ProviderName Char 51 $51. $51.
6 ProviderState Char 2 $2. $2.
4 ProviderStreetAddress Char 44 $44. $44.
7 ProviderZipCode Num 8 BEST12. BEST32.
pandyat0
Calcite | Level 5
Thank you, Reeza. This site is very helpful in describing variety of maps. I also wanted to ask how do I separate the first column into two where there is a hyphen '-' in the middle. The data is shown above. If you can please give me a suggestion on it. Thank you.
pandyat0
Calcite | Level 5
FILENAME op2013"/home/pandyat0/sasuser.v94/Outpatient_CY2013.csv" TERMSTR=LF;
/** Import the CSV file. **/
PROC IMPORT DATAFILE=op2013
OUT=WORK.op2013
DBMS=CSV
REPLACE;
GETNAMES=Yes;
guessingrows=44353;
RUN;
/*Detailed Contents of Outpatient 2013 datafile*/
proc contents data=op2013;
run;

/* MAPPING CODE STARTS BELOW: */
/*Use Mapimport to grab shapefile from zipcode folder under Files-->my_content-->zipcode
* Mapimport will import boundary file*/
proc MAPIMPORT
datafile="/home/pandyat0/my_content/zipcode/tl_2010_us_zcta510.shp"
out=WORK.zshape;
run;

/*Import Ambulatory data columns (prices)*/
*data op2013; length ProviderZipCode $5.;
*out=op2013part2;
* set op2013part2;
*out=op2013part2;
*ProviderZipCode=left(geoid);
*if state='VA';
*run;
/* Map the Data*/
ods graphics on;
ODS HTML style=statistical;
goptions ftitle='Arial';
title1 " "; title10 h=2.2 "Ambulatory Payments Classification System by Avg. Total Payments "; footnote " ";
/* colors from green->red */
pattern1 v=s c=cx00ff00; pattern2 v=s c=cx35ff00; pattern3 v=s c=cx65ff00;
pattern4 v=s c=cx88ff00; pattern5 v=s c=cx9aff00; pattern6 v=s c=cxbaff00;
pattern7 v=s c=cxccff00; pattern8 v=s c=cxd0ff00; pattern9 v=s c=cxe0ff00;
pattern10 v=s c=cxffff00; pattern11 v=s c=cxffee00; pattern12 v=s c=cxffe000;
pattern13 v=s c=cxffdd00; pattern14 v=s c=cxffdc00; pattern15 v=s c=cxffd800;
pattern16 v=s c=cxffd100; pattern17 v=s c=cxffcd00; pattern18 v=s c=cxffc000;
pattern19 v=s c=cxffb700; pattern20 v=s c=cxff9a00; pattern21 v=s c=cxff8700;
pattern22 v=s c=cxff7700; pattern23 v=s c=cxff5400; pattern24 v=s c=cxff3400;
pattern25 v=s c=cxff0000;

/*map the data from ambulatory data with shapefile as choropleth map*/
proc gmap data=op2013 map=WORK.zshape;
id ProviderZipCode; /* matches values between response and map dataset */
choro AverageTotalPayments /* response variable */
/ levels=25 /* pattern/color levels */
nolegend coutline=same /* turn off boundary lines*/;
run;quit;
ODS HTML close;
ods graphics off;
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
/*Map of US with states*/
proc gmap
map=maps.us
data=maps.us (obs=1)
all;
id state;
choro state / nolegend;
run;
/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/
I am getting an error no HTML which is below:

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
NOTE: GOPTIONS statements in the SAS Studio environment may disable some output features.
NOTE: ODS statements in the SAS Studio environment may disable some output features.
57
58 ods graphics on;
59 ODS HTML style=statistical;
NOTE: Writing HTML Body file: sashtml10.htm
ERROR: Insufficient authorization to access /pbr/biconfig/940/Lev1/SASApp/sashtml10.htm.
ERROR: No body file. HTML output will not be created.
60 goptions ftitle='Arial';
61 title1 " "; title10 h=2.2 "Ambulatory Payments Classification System by Avg. Total Payments "; footnote " ";
62 /* colors from green->red */
63 pattern1 v=s c=cx00ff00; pattern2 v=s c=cx35ff00; pattern3 v=s c=cx65ff00;
64 pattern4 v=s c=cx88ff00; pattern5 v=s c=cx9aff00; pattern6 v=s c=cxbaff00;
65 pattern7 v=s c=cxccff00; pattern8 v=s c=cxd0ff00; pattern9 v=s c=cxe0ff00;
66 pattern10 v=s c=cxffff00; pattern11 v=s c=cxffee00; pattern12 v=s c=cxffe000;
67 pattern13 v=s c=cxffdd00; pattern14 v=s c=cxffdc00; pattern15 v=s c=cxffd800;
68 pattern16 v=s c=cxffd100; pattern17 v=s c=cxffcd00; pattern18 v=s c=cxffc000;
69 pattern19 v=s c=cxffb700; pattern20 v=s c=cxff9a00; pattern21 v=s c=cxff8700;
70 pattern22 v=s c=cxff7700; pattern23 v=s c=cxff5400; pattern24 v=s c=cxff3400;
71 pattern25 v=s c=cxff0000;
72
73 /*map the data from ambulatory data with shapefile as choropleth map*/
74 proc gmap data=op2013 map=WORK.zshape;
75 id ProviderZipCode; /* matches values between response and map dataset */
76 choro AverageTotalPayments /* response variable */
77 / levels=25 /* pattern/color levels */
78 nolegend coutline=same /* turn off boundary lines*/;
79 run;

ERROR: ID variable ProviderZipCode is not found in MAP data set.
79 ! quit;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE GMAP used (Total process time):
real time 0.10 seconds
user cpu time 0.02 seconds
system cpu time 0.01 seconds
memory 5793.93k
OS Memory 36524.00k
Timestamp 11/17/2016 04:54:17 AM
Step Count 48 Switch Count 48
Page Faults 3
Page Reclaims 441
Page Swaps 0
Voluntary Context Switches 144
Involuntary Context Switches 0
Block Input Operations 1528
Block Output Operations 56

80 ODS HTML close;
81 ods graphics off;
82 /*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*
83 /*Map of US with states*/
84 proc gmap
85 map=maps.us
86 data=maps.us (obs=1)
87 all;
88 id state;
89 choro state / nolegend;
90 run;
91
92
93 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
105


My question would be do I need same Zipcode length (my file have 8 and the shape code file is 5 ) Look at 7 (last row).

Alphabetic List of Variables and Attributes
# Variable Type Len Format Informat
1 AmbulatoryPaymentClassificationG Char 85 $85. $85.
10 AverageEstimatedSubmittedCharges Num 8 NLNUM12. NLNUM32.
11 AverageTotalPayments Num 8 NLNUM12. NLNUM32.
9 OutpatientServices Num 8 BEST12. BEST32.
5 ProviderCity Char 15 $15. $15.
8 ProviderHRR Char 26 $26. $26.
2 ProviderId Num 8 BEST12. BEST32.
3 ProviderName Char 51 $51. $51.
6 ProviderState Char 2 $2. $2.
4 ProviderStreetAddress Char 44 $44. $44.
7 ProviderZipCode Num 8 BEST12. BEST32.
Darrell_sas
SAS Employee

Well, first you have an error before ProviderZipCode.  There is this:

NOTE: Writing HTML Body file: sashtml10.htm
ERROR: Insufficient authorization to access /pbr/biconfig/940/Lev1/SASApp/sashtml10.htm.
ERROR: No body file. HTML output will not be created.

 

It may be that SAS Studio cannot write to this location.  You should try something like this:

 

ods graphics on;

filename odsout 'c:\';

GOPTIONS DEVICE=png;

ODS HTML style=statistical path=odsout body="map.html";

proc gmap data=mapsgfk.world map=mapsgfk.world; id id; choro id; run; quit;

ODS HTML close;

ods graphics off;

 

Second, I think you would get a warning for 2 different lengths, not a "variable is not found" error.

Get rid of the first error first.  If the second error continues after that, make sure that your MAP data set (Work.ZSHAPE) actually has ProviderZipCode in it. 

 

You might run a piece of the program at a time and check to see that each step is behaving as you think and the data set has the variables that you think should be there.

pandyat0
Calcite | Level 5
ods graphics on;
filename odsout '/home/pandyat0/my_content/zipcode/';
GOPTIONS DEVICE=png;
ODS HTML style=statistical path=odsout body="map.html";
goptions ftitle='Arial';
/*map the data from ambulatory data with shapefile as choropleth map*/
proc gmap data=op2013 map=WORK.zshape; /*id ProviderZipCode; */
id ZCTA5CE10;
choro OutpatientServices;
run;quit;
ODS HTML close;
ods graphics off;
1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 NOTE: GOPTIONS statements in the SAS Studio environment may disable some output features.
 NOTE: ODS statements in the SAS Studio environment may disable some output features.
 57         
 58         ods graphics on;
 59         filename odsout '/home/pandyat0/my_content/zipcode/';
 60         GOPTIONS DEVICE=png;
 61         ODS HTML style=statistical path=odsout body="map.html";
 NOTE: Writing HTML Body file: map.html
 62         goptions ftitle='Arial';
 63         /*map the data from ambulatory data with shapefile as choropleth map*/
 64         proc gmap data=op2013 map=WORK.zshape; /*id ProviderZipCode; */
 65         id ZCTA5CE10;
 ERROR: Variable ZCTA5CE10 not found.
 NOTE: The previous statement has been deleted.
 66         choro OutpatientServices;
 67         run;
 
 ERROR: No ID variables specified.
 67       !     quit;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE GMAP used (Total process time):
       real time           0.01 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              3651.03k
       OS Memory           38828.00k
       Timestamp           11/22/2016 06:53:40 AM
       Step Count                        75  Switch Count  42
       Page Faults                       0
       Page Reclaims                     139
       Page Swaps                        0
       Voluntary Context Switches        112
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           72
       
 68         ODS HTML close;
 69         ods graphics off;
 70         
 71         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 83         

Hi Darrell, Thank you for your response. I tried your code and I got the errors above. I believe I need to have same length characters for ZCTA5CE10 as the file I have which has ProviderZipCode 8 Numerical (last post has that shown). I don't know what should I do to fix this error? 

 

Also, When I tried this way, it gave me 1 error instead 2. 

ods graphics on;
filename odsout '/home/pandyat0/my_content/zipcode/';
GOPTIONS DEVICE=png;
ODS HTML style=statistical path=odsout body="map.html";
goptions ftitle='Arial';
/*map the data from ambulatory data with shapefile as choropleth map*/
proc gmap data=op2013 map=WORK.zshape; /*id ProviderZipCode; */
id ProviderZipCode;
choro OutpatientServices;
run;quit;
ODS HTML close;
ods graphics off;
1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 NOTE: GOPTIONS statements in the SAS Studio environment may disable some output features.
 NOTE: ODS statements in the SAS Studio environment may disable some output features.
 57         
 58         ods graphics on;
 59         filename odsout '/home/pandyat0/my_content/zipcode/';
 60         GOPTIONS DEVICE=png;
 61         ODS HTML style=statistical path=odsout body="map.html";
 NOTE: Writing HTML Body file: map.html
 62         goptions ftitle='Arial';
 63         /*map the data from ambulatory data with shapefile as choropleth map*/
 64         proc gmap data=op2013 map=WORK.zshape; /*id ProviderZipCode; */
 65         id ProviderZipCode;
 66         choro OutpatientServices;
 67         run;
 
 ERROR: ID variable ProviderZipCode is not found in MAP data set.
 67       !     quit;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE GMAP used (Total process time):
       real time           0.03 seconds
       user cpu time       0.03 seconds
       system cpu time     0.00 seconds
       memory              5477.15k
       OS Memory           40620.00k
       Timestamp           11/22/2016 06:59:43 AM
       Step Count                        80  Switch Count  38
       Page Faults                       0
       Page Reclaims                     531
       Page Swaps                        0
       Voluntary Context Switches        97
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           96
       
 68         ODS HTML close;
 69         ods graphics off;
 70         
 71         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 83         
Darrell_sas
SAS Employee

Whatever your ID statement is, that variable must be in both your DATA= data set AND your MAP= data set.

The ID statement and variable is how it matches up the two data sets.

 

So, if you have:

proc gmap data=aaa map=bbb; id thisvar; choro chorovar; run;

 

Both data sets "aaa" and "bbb" must have "thisvar" in them or you will get an error.

"chorovar" must be in "aaa" (the DATA= data set).

 

You are getting a Error about the ID variable not being in the MAP= data set (work.zshape).

pandyat0
Calcite | Level 5
FILENAME op2013 "/home/pandyat0/sasuser.v94/Outpatient_2013withzcta.csv" TERMSTR=LF;
/** Import the CSV file.  **/
PROC IMPORT DATAFILE=op2013
		    OUT=WORK.op2013
		    DBMS=CSV
		    REPLACE;
		    GETNAMES=Yes;
		    guessingrows=44353;
RUN;
/*Detailed Contents of Outpatient 2013 datafile*/
proc contents data=op2013;
run;
/*Convert GEOID (same as zipcode) from numeric to character */
data WORK.op2013V1; set WORK.op2013;
* convert ProviderZipCode from Numeric to Character*;
ZCTA5CE10_char=put(ZCTA5CE10,5.);
drop ZCTA5CE10;
rename ZCTA5CE10_char=ZCTA5CE10;
run;
/*/////////////////////////////////////////////////////////////////////////////////////////////////////////*/
/* MAPPING CODE STARTS BELOW: */
/*Use Mapimport to grab shapefile from zipcode folder under Files-->my_content-->zipcode
* Mapimport will import boundary file*/
proc MAPIMPORT datafile="/home/pandyat0/my_content/zipcode/tl_2010_us_zcta510.shp" out=zshape;
run;
/* Map the Data*/
ods graphics on;
filename odsout '/home/pandyat0/my_content/zipcode/';
GOPTIONS DEVICE=png;
ODS HTML style=statistical path=odsout body="map.html";
goptions ftitle='Arial';
goptions cpattern=greenyellow;
goptions colors=(blue red green) ctext=black;
title1 " "; title10 h=2.2 "Ambulatory Payments Classification System by Avg. Total Payments "; footnote " ";
/* colors from green->red */
pattern1 v=s c=cx00ff00; pattern2 v=s c=cx35ff00; pattern3 v=s c=cx65ff00;
pattern4 v=s c=cx88ff00; pattern5 v=s c=cx9aff00; pattern6 v=s c=cxbaff00;
pattern7 v=s c=cxccff00; pattern8 v=s c=cxd0ff00; pattern9 v=s c=cxe0ff00;
pattern10 v=s c=cxffff00; pattern11 v=s c=cxffee00; pattern12 v=s c=cxffe000;
pattern13 v=s c=cxffdd00; pattern14 v=s c=cxffdc00; pattern15 v=s c=cxffd800;
pattern16 v=s c=cxffd100; pattern17 v=s c=cxffcd00; pattern18 v=s c=cxffc000;
pattern19 v=s c=cxffb700; pattern20 v=s c=cxff9a00; pattern21 v=s c=cxff8700;
pattern22 v=s c=cxff7700; pattern23 v=s c=cxff5400; pattern24 v=s c=cxff3400;
pattern25 v=s c=cxff0000; 
/*map the data from ambulatory data with shapefile as choropleth map*/
proc gmap data=WORK.op2013V1 map=zshape; /*id ProviderZipCode; */
id ZCTA5CE10;
choro avgpymnt / levels= 25 nolegend coutline= same;
run;quit;
ODS HTML close;
ods graphics off;

Now I have a map with just one color. sasmap.png

I want to use choro avrgpaymnt to give gradients with red yellow green heatmap. The avgpymny values are ranging from $0.00 to $ 20,000.00, How do I write a for loop or some loop to give different color granularity. Thanks.

pandyat0
Calcite | Level 5

I have changed the data file a little. I have downloaded a gazateer data from the tutorial http://support.sas.com/resources/papers/proceedings13/214-2013.pdf . After then I added a new column called average medicare payments in excel. I then used VLOOKUP to match the prices with zipcode or GEOID. (Click Here use VLOOKUP.). Here is the screenshot of what my dataset looks like. Also I renamed Zipcode as ZCTA5CE10 (Also right click on that column and go to format cells and go to Custom and under Types: type--> 00000  ( which will change to text as 5 characters.) 

 

 datasample.png

Then save excel file as csv or txt and upload that file on SAS Studio. I have then save that file on directory for furuther analysis and used code below.

pandyat0
Calcite | Level 5
 **STEP 1: Get the data from the directory;
FILENAME op2013 "/home/pandyat0/sasuser.v94/Outpatient_CY2013.csv" TERMSTR=LF;

/** Data imported as .CSV file format. **/
PROC IMPORT DATAFILE=op2013 OUT=WORK.op2013 DBMS=CSV REPLACE;
GETNAMES=Yes;
guessingrows=44353;
RUN;

/*STEP 2: Chech the contents within the data. */
/*Detailed Contents of Outpatient 2013 datafile*/
proc contents data=op2013;
run;

/*STEP 3: Convert variables into necessary format. (Char to Num., vice versa.) */
/*Convert GEOID (same as zipcode) from numeric to character */
data WORK.op2013V1;
set WORK.op2013;
* convert ProviderZipCode from Numeric to Character*;
ZCTA5CE10_char=put(ZCTA5CE10, 5.);
AverageTotalPayments_num=INPUT(AverageTotalPayments, 8.0);
drop ZCTA5CE10;
rename ZCTA5CE10_char=ZCTA5CE10;
*AverageTotalPayments_num=INPUT(AverageTotalPayments, 8.0);
*drop AverageTotalPayments;
*rename AverageTotalPayments_num=AverageTotalPayments;
run;

proc contents data=op2013V1;
run;
*data WORK.op2013V1;
*set WORK.op2013;
* convert AverageTotalPayments from Character to Numeric*;
*AverageTotalPayments_num=INPUT(AverageTotalPayments, 8.0);
*drop AverageTotalPayments;
*rename AverageTotalPayments_num=AverageTotalPayments;
*run;

/*STEP 4: Mapimport will import boundary file as .shp format*/
proc MAPIMPORT
datafile="/home/pandyat0/my_content/zipcode/tl_2010_us_zcta510.shp"
out=zshape;
run;

proc contents data=zshape; run;
/*STEP 5: Map the data using GMAP procedure*/
GOPTIONS DEVICE=png cback=white noborder;
ods listing close;
*ods graphics on;
filename odsout '/home/pandyat0/my_content/zipcode/';
ODS HTML path=odsout body="map.html";
goptions htitle=4 ftitle="Thorndale AMT/bold"
htext=3 ftext="Thorndale AMT" ctext=gray55;
footnote1 "";
title1 h=2.2 "Ambulatory Payments Classification System";

/* colors from green->red */
pattern1 v=s c=cx00ff00;
pattern2 v=s c=cx35ff00;
pattern3 v=s c=cx65ff00;
pattern4 v=s c=cx88ff00;
pattern5 v=s c=cx9aff00;
pattern6 v=s c=cxbaff00;
pattern7 v=s c=cxccff00;
pattern8 v=s c=cxd0ff00;
pattern9 v=s c=cxe0ff00;
pattern10 v=s c=cxffff00;
pattern11 v=s c=cxffee00;
pattern12 v=s c=cxffe000;
pattern13 v=s c=cxffdd00;
pattern14 v=s c=cxffdc00;
pattern15 v=s c=cxffd800;
pattern16 v=s c=cxffd100;
pattern17 v=s c=cxffcd00;
pattern18 v=s c=cxffc000;
pattern19 v=s c=cxffb700;
pattern20 v=s c=cxff9a00;
pattern21 v=s c=cxff8700;
pattern22 v=s c=cxff7700;
pattern23 v=s c=cxff5400;
pattern24 v=s c=cxff3400;
pattern25 v=s c=cxff0000;

/*map the data from ambulatory data with shapefile as choropleth map*/
proc gmap data=WORK.op2013V1 map=Work.zshape;
id ZCTA5CE10;
choro AverageTotalPayments_num / levels=25
nolegend
coutline=black
Statistic=first;
run;
quit;
ODS HTML close;
ods listing;
*ods graphics off;
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 NOTE: GOPTIONS statements in the SAS Studio environment may disable some output features.
 NOTE: ODS statements in the SAS Studio environment may disable some output features.
 57         
 58         GOPTIONS DEVICE=png cback=white noborder;
 59         ods listing close;
 60         *ods graphics on;
 61         filename odsout '/home/pandyat0/my_content/zipcode/';
 62         ODS HTML path=odsout body="map.html";
 NOTE: Writing HTML Body file: map.html
 63         goptions htitle=4 ftitle="Thorndale AMT/bold"
 NOTE: No units specified for the HTITLE option. The current units associated with GUNIT will be used.
 64                  htext=3  ftext="Thorndale AMT" ctext=gray55;
 NOTE: No units specified for the HTEXT option. The current units associated with GUNIT will be used.
 65         footnote1 "";
 66         title1 h=2.2 "Ambulatory Payments Classification System";
 67         
 68         /* colors from green->red */
 69         pattern1  v=s c=cx00ff00;
 70         pattern2  v=s c=cx35ff00;
 71         pattern3  v=s c=cx65ff00;
 72         pattern4  v=s c=cx88ff00;
 73         pattern5  v=s c=cx9aff00;
 74         pattern6  v=s c=cxbaff00;
 75         pattern7  v=s c=cxccff00;
 76         pattern8  v=s c=cxd0ff00;
 77         pattern9  v=s c=cxe0ff00;
 78         pattern10 v=s c=cxffff00;
 79         pattern11 v=s c=cxffee00;
 80         pattern12 v=s c=cxffe000;
 81         pattern13 v=s c=cxffdd00;
 82         pattern14 v=s c=cxffdc00;
 83         pattern15 v=s c=cxffd800;
 84         pattern16 v=s c=cxffd100;
 85         pattern17 v=s c=cxffcd00;
 86         pattern18 v=s c=cxffc000;
 87         pattern19 v=s c=cxffb700;
 88         pattern20 v=s c=cxff9a00;
 89         pattern21 v=s c=cxff8700;
 90         pattern22 v=s c=cxff7700;
 91         pattern23 v=s c=cxff5400;
 92         pattern24 v=s c=cxff3400;
 93         pattern25 v=s c=cxff0000;
 94         
 95         /*map the data from ambulatory data with shapefile as choropleth map*/
 96         proc gmap data=WORK.op2013V1 map=Work.zshape;
 97         id ZCTA5CE10;
 98         choro AverageTotalPayments_num / levels=25
 99          nolegend
 100         coutline=black
 101         Statistic=first;
 102        run;
 
 ERROR: No valid levels for a map.
 ERROR: No valid levels for a map.
 ERROR: No valid levels for a map.
 ERROR: No valid levels for a map.
 103        quit;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE GMAP used (Total process time):
       real time           11.93 seconds
       user cpu time       9.34 seconds
       system cpu time     2.60 seconds
       memory              7975.84k
       OS Memory           42716.00k
       Timestamp           11/27/2016 05:48:21 PM
       Step Count                        64  Switch Count  78
       Page Faults                       0
       Page Reclaims                     1636
       Page Swaps                        0
       Voluntary Context Switches        242
       Involuntary Context Switches      37
       Block Input Operations            0
       Block Output Operations           264
       
 104        ODS HTML close;
 105        ods listing;
 106        
 107        
 108        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 120        

I am getting errors : No valid levels for a map. I dont know how to get rid of these errors. Just so you know, I am running this code on SAS Studio and I don't know if SAS studio is not recognizing these functions. Any help is greatly appreciated. Thank you. 

 

pandyat0
Calcite | Level 5

I did have working ODS graphics working before (like 2 days ago!) but now its saying that ERROR: NO VALID LEVELS FOR A MAP.

I have inserted image below of what I had before, I am trying to get that image back. I tried to make that code (which gave me an image) work little better and I messed it up. I guess thats what happened. Can anyone please let me know what can I do to remove those errors of no valid levels for a map. Just a note, I am using SAS STUDIO. I also have attached logs as well as codes of what i have so far. 

averageambulatorycostsbyzipcode.png

I have used the example from sas support files, http://support.sas.com/resources/papers/proceedings13/214-2013.pdf

and the forum above to make the code that gave me this map. 

I have used levels = 25 for this map which I dont know how it binned out (which color represents which values). Let me know what you think and as always any help is greatly appreciated!

-pandyat0

pandyat0
Calcite | Level 5

How to resolve SAS Studio error proc gmap ERROR: No valid levels for a map.  in Sas studio.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 2074 views
  • 0 likes
  • 4 in conversation