Hey guys,
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?
Thanks,
Kelly867
Anythings possible with enough time, money and people.
For your problem you need to provide more details. A good way would be with sample data.
Okay...
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?
- Kelly867
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.
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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.