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

Hopefully there is an easy solution to this problem...

Question: What type of insurance do you have? (check all that apply)

Private insurance provided by employer q99r1

  Insurance provider through family member employer  q99r2

  Insurance purchased directly from insurance company  q99r3

......

I would like to group these insurance types into smaller groups, however when running the following code, I do not get true values.

data work.pwl_spss; /****message 10****/ 

set work.pwl_spss;

if q99r1 = 1 then  q99m = 1 ;/***Private***/

if q99r2 = 1 then  q99m=1;

if q99r3 = 1 then  q99m=1;

if q99r9 = 1 then  q99m=1;

if q99r4 = 1 then  q99m=1;

if q99r7 = 1 then  q99m=2; /**2=Medicare***/

if q99r8 = 1 then  q99m=2;

if q99r10 = 1 then  q99m=3; /****3=Medicaid***/

if q99r11 = 1 then  q99m=4; /***4=Other***/

if q99r12 = 1 then  q99m=4;

if q99r13 = 1 then  q99m=4;

if q99r6 = 1 then  q99m=4;

if q99r14 = 1 then  q99m=6;/***6=Not Sure***/

run;

For example, when adding together q99r1- q99r4, I get 562, but when running this code I get 472.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Post an example subset of your data and expected result. I'm not sure why you keep talking about these sums as they are irrelevant for recoding multiple variables into one due to the multiple response nature of the data.

And if you are recoding before cleaning the data, since you say you have values of 2 that should be 0/1 then you may have other issues.

What value do you want q99m to be when all of q99r1, q99r6,q99r7 and q99r10 are equal to 1? You are quite likely to have responses that in multiple of you target range, especially Private and Other (betting that your other includes Champus/Tricare military and/or Indian health services or similar) and not impossible to have overlaps with Private and Medicare. Less likely but you may even have overlaps with medicaid.

Your existing code in my example question is going to assign 4 but your looking at the private only variables woud expect you to have a private assignment.

You have to determine a priority which will mask some of your results.

I would usually create 5 dichotomous variables for the target groups so that I would be able to analyze within respondents that had any private insurance as well as any medicare or "other".

View solution in original post

7 REPLIES 7
stat_sas
Ammonite | Level 13

This is because you are counting multiple responses once.

e.g

q99r1 q99r2 q99r3 q99r9   q99m

1          1        1         1          1

1          0        0         0          1

so frequency for

q99m=2

while total frequency for q99r1 +  q99r2 + q99r3 + q99r9 is 5

Ksharp
Super User

data work.pwl_spss; /****message 10****/

set work.pwl_spss;

if q99r1 = 1 then  q99m = 1 ;/***Private***/

else if q99r2 = 1 then  q99m=1;

else if q99r3 = 1 then  q99m=1;

else if q99r9 = 1 then  q99m=1;

else if q99r4 = 1 then  q99m=1;

else if q99r7 = 1 then  q99m=2; /**2=Medicare***/

else if q99r8 = 1 then  q99m=2;

else if q99r10 = 1 then  q99m=3; /****3=Medicaid***/

else if q99r11 = 1 then  q99m=4; /***4=Other***/

else if q99r12 = 1 then  q99m=4;

else if q99r13 = 1 then  q99m=4;

else if q99r6 = 1 then  q99m=4;

else if q99r14 = 1 then  q99m=6;/***6=Not Sure***/

run;   



??????????

GregBond
Obsidian | Level 7

Hi KSharp,

I have tried that method of code as well, but it is still not giving me the true value, I am surely lost in this.

When adding,  q99r1 q99r2 q99r3 q99r4 and q99r9 i get 562. When using the code mentioned in my first comment, I get 472. When using the code mentioned by stat@sas I get 1=546,  2=8 (no clue where the

'2' came from as the repsonse options are 1 for 0 for no).  When using the code mentioned by Ksharp, the output is 554.  Thanks for everyone's help thus far, very much appreciated!

ballardw
Super User

Post an example subset of your data and expected result. I'm not sure why you keep talking about these sums as they are irrelevant for recoding multiple variables into one due to the multiple response nature of the data.

And if you are recoding before cleaning the data, since you say you have values of 2 that should be 0/1 then you may have other issues.

What value do you want q99m to be when all of q99r1, q99r6,q99r7 and q99r10 are equal to 1? You are quite likely to have responses that in multiple of you target range, especially Private and Other (betting that your other includes Champus/Tricare military and/or Indian health services or similar) and not impossible to have overlaps with Private and Medicare. Less likely but you may even have overlaps with medicaid.

Your existing code in my example question is going to assign 4 but your looking at the private only variables woud expect you to have a private assignment.

You have to determine a priority which will mask some of your results.

I would usually create 5 dichotomous variables for the target groups so that I would be able to analyze within respondents that had any private insurance as well as any medicare or "other".

GregBond
Obsidian | Level 7

Hope this helps in explaining my issue, and thank you again for your conintued help.

When I run q99r1, q99r2,q99r3, q99r3 and q99r9 individually, their respecitve counts are 260, 234, 33, 13, and 22 which adds up to 562.  When I have tried running the aforemention codes, neither has given my the value of 562.

When either q99r1, q99r2,q99r3, q99r3 and q99r9 equals '1(yes)', I want the sum of the dummy variable which groups these varaibles to be 562.

IDq99r1 q99r2 q99r3
1yesyesno
2noyesno
3noyesyes
4no nono
5yesnono
ballardw
Super User

But what do you want as a result in the case I mentioned? You have a single outcome variable Q99M which also gets assigned when variables other than q99r1-4 and 9. As long as you have multiple variables in addition to those that set q99m then you are going to have inconsistency. If you want a varaible assigned just for that group you can use something like:

Q99g1 = (max( of q99r1-q99r4, q99r9) = 1);

and additional group variables for the other combinations.

However if you still have values of 2 when you say they should be 1 and 0 then you've still got other problems.

GregBond
Obsidian | Level 7

Thank you ballrdw! That response seems to have worked for the grouping every insurance group except "Private" where 8 are still missing, assuming those are the 8 listed as "2". Went through the dataset and all responses are either 'yes' 'no' so I'll try to figure this out on my own.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 7 replies
  • 1146 views
  • 7 likes
  • 4 in conversation