BookmarkSubscribeRSS Feed
kelly867
Calcite | Level 5

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

4 REPLIES 4
Reeza
Super User

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.

kelly867
Calcite | Level 5

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

Reeza
Super User

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. 

 

PGStats
Opal | Level 21

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;
PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 2341 views
  • 1 like
  • 3 in conversation