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

I am working with a dataset similar in format to the table below as an example. I need to merge this health insurance dataset with another medical dataset based on ID. That part is simple enough. However, for the insurance dataset, I need to create one row for each patient that describes their health insurance status (0=no insurance; 1=insurance) for the month of each year similar to the table below. If a patient moved to another state they have a different row that identifies their insurance status in that specific state. In my example table below I need one row that shows that patient having continuous coverage even though they lost it in one state and gained it in another. Additionally, if patients have health insurance coverage in two states at the same time point they need to be removed. I am not sure how to proceed with code that can accomplish this task. Any help or suggestions would be appreciated.

 

 

IDStateMatch_numJan-06Feb-06Mar-06Apr-06May-06Jun-06Jul-06Aug-06Sep-06Oct-06Nov-06Dec-06Jan-07Feb-07Mar-07Apr-07May-07Jun-07Jul-07Aug-07Sep-07Oct-07
123456CA600000011111111111111  
123456WA611111100000000000000  
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
proc summary nway data=have;
    class id;
    var <your variable names go here>;
    output out=want sum=;
run;

 

This gives you one row per patient, with a 1 if they had insurance in any state and a zero if they did not have insurance in any state. If any of the variables in the output data set have a value of two or more, then they had insurance in two or more states.

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26
proc summary nway data=have;
    class id;
    var <your variable names go here>;
    output out=want sum=;
run;

 

This gives you one row per patient, with a 1 if they had insurance in any state and a zero if they did not have insurance in any state. If any of the variables in the output data set have a value of two or more, then they had insurance in two or more states.

--
Paige Miller
gabe434555
Fluorite | Level 6
Oh my goodness! Thank you!

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
  • 308 views
  • 1 like
  • 2 in conversation