BookmarkSubscribeRSS Feed
gtucke1
Fluorite | Level 6

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.

6 REPLIES 6
Tom
Super User Tom
Super User

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? 

ballardw
Super User

@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? 


@Tom 

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.

PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
gtucke1
Fluorite | Level 6

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...).

Tom
Super User Tom
Super User

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;
gtucke1
Fluorite | Level 6

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 6 replies
  • 777 views
  • 0 likes
  • 4 in conversation