BookmarkSubscribeRSS Feed
MisoLee
Calcite | Level 5

Hi, everyone!

I am sort of self learning to use SAS and hopefully everyone can give me some advice to address my questions. My one-year data set has these fields: hospital id, hospital name, state, city, race/ethnicity, sex, number of cases, mean LOS, primary payer, and so on. I actually want to map the average LOS overall in each state, and then stratified by race/ethnicity in each state. So I am wondering how to start, where I shall get map (shape file with 50 state names but not zipcode), what SAS codes I shall use...etc.

ID           Cases   State   Race   LOS      Insurance

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

00001       500      AZ      White   5.5     Medicaid

00001       50        AZ      Black   6.0     Medicaid

00001      1000     AZ      White   4.5     Medicare

00001       2000    AZ      Black   3.2     Medicare

00002      1000     TX      White   4.9     Medicaid

00002      700       TX      Black   6.6      Medicaid

00002      30000    TX      White   4.0     Medicare

00002     18000     TX      Black   3.9      Medicare

Thank you!

Miso

5 REPLIES 5
GraphGuy
Meteorite | Level 14

Here are the basics that should get you started...

data my_data;

length statecode $2 race $5 insurance $20;

input ID  Cases Statecode Race LOS Insurance;

datalines;

00001       500      AZ      White   5.5     Medicaid

00001       50        AZ      Black   6.0     Medicaid

00001      1000     AZ      White   4.5     Medicare

00001       2000    AZ      Black   3.2     Medicare

00002      1000     TX      White   4.9     Medicaid

00002      700       TX      Black   6.6      Medicaid

00002      30000    TX      White   4.0     Medicare

00002     18000     TX      Black   3.9      Medicare

;

run;

proc gmap data=my_data map=maps.us all;

id statecode;

choro LOS / statistic=mean levels=5;

run;

ballardw
Super User

May need to summarize the data before mapping to apply the weight of the number of cases:

proc summary data=my_data nway;

class statecode;

var Los;

weight cases;

output out=mapdata mean=;

run;

and use

proc gmap data=mapdata map=maps.us all;

You may need to clarify what you mean by stratify by race. A separate map for each level of race you could add race to the

class statement of proc summary above: class race statecode;

and use a BY RACE in the GMAP code.

Darrell_sas
SAS Employee


I would recommend you use MAPSGFK instead of MAPS.

MAPS is going away.  It isn't being updated.

Just change Robert's example from MAPS to MAPSGFK and it will work.

MisoLee
Calcite | Level 5

To answer ballardw: I want to see the average LOS for each racial group in each state. I am not sure what it will look like in SAS. Next, if I want to adjust the LOS by insurance, how should I proceed it? Thank you!

ballardw
Super User

40502 - Annotate a pie chart in selected states with PROC GMAP shows an example of showing a pie chart on each state which may get you started.

You can also spend a lot of time at Robert Allison's SAS/Graph Examples! for many examples of graphs and maps.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1940 views
  • 10 likes
  • 4 in conversation