Hello,
I have 4 variables (coded 1=yes; 0=no) that tap into whether respondents used social media devices with parents, friends, relatives, and other adults.
I want to create a single variable that takes the following variables:
1 if discussed with parents
2 if discussed with friends
3 if discussed with relatives
4 if discussed with other adults
5 if discussed with parents and friends
6 if with parents and relatives
7 if with parents and other adults
8 if discussed with any combination all four
9 if discussed with all four
I used the following command,
gen most_use_sources = .
replace most_use_sources=1 if parents_dum==1
replace most_use_sources=2 if relatives_dum==1
replace most_use_sources=3 if friends_dum==1
replace most_use_sources=4 if otheradults_dum==1
replace most_use_sources=5 if parents_dum==1 & relatives_dum==1
replace most_use_sources=6 if parents_dum==1 & friends_dum==1
replace most_use_sources=7 if parents_dum==1 & otheradults_dum==1
replace most_use_sources=8 if num_source==3
replace most_use_sources=9 if num_source==4
However, the number of cases I am getting for the categories of the new variable are much much lower than the number of cases for each of the dummy variables separately. For example, the dummy for parents had about 900 cases, but there are only 44 cases for the parent category in the newly created most_use_sources =1 category.
I will appreciate some help to tease out these differences.
thanks - cY
Related Posts with Create a variable from other dummies
Collapse command - data precisionHello, I am working with a dataset that contains dollar amounts that range from $0 to several milli…
Conflicting goodness of fit results - Poisson distributionHello everyone, I hope you are well! I'm running a regression which examines the impact of the prop…
t-stat table difference by groupsHello Statalisters, I have the following dataset, Code: * Example generated by -dataex-. To insta…
replace missing values with values from another group / the mean of two groups↵ Dear, I am trying write a loop or program : - for var1 : replace the missing value (2012) by the…
Analysis of Ranked VaribalesDear All, I need some help in analyzing my ranked variables. In my survey I asked to select the top…
Subscribe to:
Post Comments (Atom)
0 Response to Create a variable from other dummies
Post a Comment