Hello Listservers,
i have 3 variables:
X (use of anal-condom)
Y (use of oral condom)
Z (use of vaginal condom)
Each as is coded 1=Yes, 2=No, 0,8,9=Missing.
I want to create a new variable that is set to 1 (CONDUSE = 1), if the respondent uses condom for any type of sex, 2, if not. Here is an example of the scratch data
Code:
| ANALCOND ORALCOND VAGCOND conduse | |-----------------------------------------| 221. | 0 0 0 . | 222. | 0 0 0 . | 223. | 0 0 0 . | 224. | 0 0 0 . | 225. | 0 0 0 . | |-----------------------------------------| 226. | 0 2 2 2 | 227. | 0 0 0 . | 228. | 0 1 1 1 | 229. | 0 2 1 2 | 230. | 0 0 0 . | |-----------------------------------------| 231. | 0 0 0 . | 232. | 0 0 0 . | 233. | 0 2 2 2 | 234. | 0 0 0 . | 235. | 0 1 1 1 | |-----------------------------------------|
I tried the following command:
Code:
/* Create conduse = use of condom */ gen conduse=1 if ANALCOND==1 | ORALCOND==1 | VAGCOND==1 replace conduse=2 if ANALCOND==2 | ORALCOND==2 | VAGCOND==2 fre conduse
I will appreciate some help from you all.
thanks - Cy
Comment