09-15-2017 10:21 PM
I need help creating a variable for sex. My data set currently has variables called "male" and "female, which have a numeric value for each observation. However, I am trying to create one variable for each observation called "sex", which should indicate the number of male and female participants in each observation. Is this possible?
09-15-2017 10:55 PM
Attached is a screenshot of the variables I have for my first 4 observations. I have 2 variables (numbermale and numberfemale) that I somehow want to combine into one variable.
The overall purpose of doing this is to create a variable that can be used for logistic regression. Sex is one of my predictor variables.
Am I approaching this wrong? Is there another option for running logistic regression with these variables?
09-15-2017 11:02 PM
This isn't making sense to me. You typically do logistic regression with individual level data. If this isn't individual level data then I don't know how you'd combine this to make any sort of sense...in that case, leaving it as is seems to make the most amount of sense. You can't combine it to a single person and then use all three variables, you could combine it and use that vairable alone, and not use the gendered breakdown.
What are you expecting as output from combining these variables?
Note that we can't provide code based on images, and I'm not typing out your data for an example AND code that answers it. Please provide data samples as text.
09-15-2017 11:03 PM
Ths is how to do ths:
data want; set have; if numberFemale > 0 then do; sex = "Female"; number = numberFemale; output; end; if numberMale > 0 then do; sex = "Male"; number = numberMale; output; end; drop numbermale numberfemale; run;