Hello,
currently I'm trying to build a new variable out of an already existing one.
The existing one needs to be recoded so that the direction of the value is changed (So that 5 equals 1 etc., 4 equals 2 etc.).
Also, I want to round up the values to numeric numbers without decimal places.
*The existing variable
egen help=rownonmiss(pcr1i3 pcr1i8 pcr1i11)
egen negcomm_pacs=rowmean(pcr1i3 pcr1i8 pcr1i11)
if inlist(help,2,3)
drop help
label var negcomm_pacs "Negative communication in parenting style"
label def negcomm_pacs 1 "1 low" 5 "5 high"
label val negcomm_pacs negcomm_pacs
Negative |
communicatin |
on | Freq. Percent Cum.
------------+-----------------------------------
1 | 11 1.43 1.43
1.333333 | 27 3.52 4.95
1.666667 | 63 8.21 13.17
2 | 134 17.47 30.64
2.333333 | 183 23.86 54.50
2.5 | 1 0.13 54.63
2.666667 | 144 18.77 73.40
3 | 118 15.38 88.79
3.333333 | 46 6.00 94.78
3.666667 | 23 3.00 97.78
4 | 15 1.96 99.74
4.333333 | 1 0.13 99.87
4.666667 | 1 0.13 100.00
------------+-----------------------------------
Total | 767 100.00
*Command for the new variable, which doesn't work
gen negcomm = negcomm_pacs
replace negcomm = 5 if (negcomm_pacs==.6666667/1.333333) //
replace negcomm = 4 if (negcomm_pacs==1.666667/2.333333) //
replace negcomm = 3 if (negcomm_pacs==2.666667/3.333333) //
replace negcomm = 2 if (negcomm_pacs==3.666667/4.333333) //
replace negcomm = 1 if (negcomm_pacs==4.666667/5) //
replace negcomm = 0 if (negcomm_pacs==-2)
Do you have any idea, why this command doens't work?
Thanks in advance!
currently I'm trying to build a new variable out of an already existing one.
The existing one needs to be recoded so that the direction of the value is changed (So that 5 equals 1 etc., 4 equals 2 etc.).
Also, I want to round up the values to numeric numbers without decimal places.
*The existing variable
egen help=rownonmiss(pcr1i3 pcr1i8 pcr1i11)
egen negcomm_pacs=rowmean(pcr1i3 pcr1i8 pcr1i11)
if inlist(help,2,3)
drop help
label var negcomm_pacs "Negative communication in parenting style"
label def negcomm_pacs 1 "1 low" 5 "5 high"
label val negcomm_pacs negcomm_pacs
Negative |
communicatin |
on | Freq. Percent Cum.
------------+-----------------------------------
1 | 11 1.43 1.43
1.333333 | 27 3.52 4.95
1.666667 | 63 8.21 13.17
2 | 134 17.47 30.64
2.333333 | 183 23.86 54.50
2.5 | 1 0.13 54.63
2.666667 | 144 18.77 73.40
3 | 118 15.38 88.79
3.333333 | 46 6.00 94.78
3.666667 | 23 3.00 97.78
4 | 15 1.96 99.74
4.333333 | 1 0.13 99.87
4.666667 | 1 0.13 100.00
------------+-----------------------------------
Total | 767 100.00
*Command for the new variable, which doesn't work
gen negcomm = negcomm_pacs
replace negcomm = 5 if (negcomm_pacs==.6666667/1.333333) //
replace negcomm = 4 if (negcomm_pacs==1.666667/2.333333) //
replace negcomm = 3 if (negcomm_pacs==2.666667/3.333333) //
replace negcomm = 2 if (negcomm_pacs==3.666667/4.333333) //
replace negcomm = 1 if (negcomm_pacs==4.666667/5) //
replace negcomm = 0 if (negcomm_pacs==-2)
Do you have any idea, why this command doens't work?
Thanks in advance!
Comment