Good day Stata Friends,
I am trying to generate and replace a variable in Stata.
My study is on adolecents ages 10 - 19 year olds.
I have 2 school_fees variables data sets in 2 different files for each wave (5 waves in total). One file is for children 0-14 year old (nfs2); the other file is for adults above 14 (nfs1). In South Africa, schools that do not pay school fees (nfs) participate in feeding school program. I would like to generate a new variable, feeding scheme program (fsp).
I tried the following
First
gen nfs1 = schoolfees1 if child_age1>9 & child_age1<20
gen nfs2 = schoolfees2 if child_age1>9 & child_age1<20
gen fsp1 = nfs1 + nfs2
It came out blank
Second
gen nfs1 = schoolfees1 if child_age1>9 & child_age1<20
gen nfs2 = schoolfees2 if child_age1>9 & child_age1<20
gen fsp1 = 1 if nfs1>10 & nfs7>10 & (child_age1>9 & child_age1<20)
replace fsp1 = 0 if nfs1<=10 & nfs7<=10
This also came out wrong; showing only 1s and all over the place
In short, I would like nfs1 and nfs2 to be in the same row.
Thanks in advance.
Nthato
Related Posts with Generate and Replace
Help need please for a foreach commandDear Statalists, I'm wondering if anyone could help me on this. I have a dataset containing 26 vari…
Reghdfe and margins?Hi, I am using reghdfe (nov19 versions) and need to estimate margins after that (I know there used …
Create parent child links in panel dataHi everyone, I am working with a panel data set and want to create intergenerational linkages betwe…
testing marginal effects after bivariate probit modelDear all, I estimate 3 bivariate probit models (for three countries), using biprobit command with r…
How to create a new dataset from r(name) after a r-class command I would like to ask how to create a new dataset from r(name) after a r-class command I am analy…
Subscribe to:
Post Comments (Atom)
0 Response to Generate and Replace
Post a Comment