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
🗎 Temporary file with -tempfile-Dear All, I am looking for a way to make use of temporary files with the putpdf image command. Unfo…
Event study standard deviation for t-testHi, I'm currently doing an event study using a sample of firms and a three days event window [-1,+1…
Restricting Loop to Observation NumberI wish to create a variable that looks something like 1994M1, 1994M2.....1994M12 to indicate the mon…
how stata applys to treat tobit model- payment card approachHi college, I am learning econometrics on my own (as it is not my major in university), but hope to …
Generate new variable based on existing dataI am using Stata 16.1 and would like to generate a new variable based on the ADM1 (region) name and …
Subscribe to:
Post Comments (Atom)
0 Response to Create a variable from other dummies
Post a Comment