BookmarkSubscribeRSS Feed
Suf12345
Calcite | Level 5
I am looking to create a new variable for employment. The way it is coded right now does not give me the correct frequency distribution because the variables are overlapping. For example, an individual selected income_1 and income_21. This should both go in two groups. For example,  group 1 and group 4.  SAS is counting the individual for one group and not the other. I am guessing it is because an individual cannot be present in both groups. 
I have tried different methods but nothing seems to work. Do you recommend any way of handling overlapping variables? I have attached the code below. 
 
*creating an employement variable;
if income_flag=0 then do;
if income_1 eq 1 or income_2 eq 1 or income_3 eq 1 then employment_4cat=1;/* group 1*/
if income_12 eq 1 or income_13 eq 1 or income_14 eq 1 or income_15 eq 1 or income_16 eq 1 or income_17 eq 1 then employment_4cat=2; /*group 2*/
if income_6 eq 1 or income_7 eq 1 or income_8 eq 1 or income_9 eq 1 or income_10 eq 1 or income_21 eq 1 then employment_4cat=2= 3;/*group 3*/  
if income_4 eq 1 or income_5 eq 1 or income_11 eq 1 or income_18 eq 1 or income_19 eq 1 or income_compl= "18 years old, left home 2 weeks ago, no source of income at all" then employment_4cat=2=4; /*group 4*/
end;
if income_flag=1 then employment_4cat=.;
label employment_4cat= "Employment Status";

run;

2 REPLIES 2
PaigeMiller
Diamond | Level 26

For example, an individual selected income_1 and income_21. This should both go in two groups. For example,  group 1 and group 4. 


From your code, it looks as if this individual should be in groups 1 and 3. Am I understanding you properly?

 

If you want an individual to be in two groups, there are a number of solutions:

 

  1. multiple records for this individual
  2. multiple variables to indicate multiple group membership
  3. a text string, such as "1 3" to indicate that the indivdiual is in groups 1 and 3.

 

Which would you prefer? I vote for #1, it has the most advantages and the fewest drawbacks, in my opinion, although it really depends on what happens next. So, I ask the obvious question: what is the next step, what analysis, chart or report are you going to do?

--
Paige Miller
Suf12345
Calcite | Level 5

Thanks for your input! 

 

How would you go about creating multiple records for each individual?

 

This variable would be one of my independent variables for my analysis. The next step would be to: 

  1. Create a frequency table comparing individuals in the different groups 
  2. Conduct a Poisson Logistic Regression Analysis looking at the association between this variable and the independent variable 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1002 views
  • 0 likes
  • 2 in conversation