The variable is now a dichotomous variable with 0 = spousal and 1 = nonspousal. In order to do analyses comparing these two variables against other variables I think I need to make them each a new variable. Is this correct? If yes, how would I go about doing that? If no, how do I compare these two variables against other variables?
Data X
Set Y
if cg_relation___1 = 1 then cg_relationr = 0;
if cg_relation___2 = 1 then cg_relationr = 1;
if cg_relation___3 = 1 then cg_relationr = 1;
if cg_relation___4 = 1 then cg_relationr = 1;
if cg_relation___5 = 1 then cg_relationr = 1;
if cg_relation___7 = 1 then cg_relationr = 1;
if cg_relation____8 = 1 then cg_relationr = .;
if cg_relation____9 = 1 then cg_relationr = .;
Run;
Thank you for the help. I'm a newbie.
If the only possible meanings are SPOUSAL and NON_SPOUSAL then a single variable with two levels how ever they are coded captures all of the information.
But what are these other variables you are referencing in the code?
@Tom wrote:
If the only possible meanings are SPOUSAL and NON_SPOUSAL then a single variable with two levels how ever they are coded captures all of the information.
But what are these other variables you are referencing in the code?
I would place a small wager that this comes from some sort of "select one choice question" that has 8 choices. For bonus cash would also wager that 7 is some sort of "Other" with 8 and 9 the equivalents of Don't know, Not applicable and/or Refused to answer and the export dumps the data to one variable per choice.
@gtucke1 wrote:
The variable is now a dichotomous variable with 0 = spousal and 1 = nonspousal. In order to do analyses comparing these two variables against other variables I think I need to make them each a new variable. Is this correct?
No not correct at all. But you don't tell us what analysis you are going to do, we'd need to know this in order to advise in more detail.
I will be comparing the spousal status (spousal non-spousal) to the number and type of unmet needs. There are 18 different types of needs (health care, education...).
So you have data like:
data have ;
input id $ spouse need1-need18;
How are you planning to compare them?
Do you just want to look at distributions?
proc means data=have;
class spouse;
var need1-need18;
run;
I would like to look at distribution but also come up with a total percent of unmet needs for the 18 items.
Of X number of participants, X had __% of unmet needs.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.