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
Invalid name in foreach loopHi all, I'm trying to iterate over two variables, with the names "category" and "month_created". Th…
Please Help with CodeHi All, I am trying to make a variable that identifies whether a person's second to last work histor…
Negative statistic chi2 after hausman testHello everyone, I have panel data and my dependent variable is a dummy variable. N=801 (individuals)…
Merging two data sets based on ranges and assign a numberI would like to merge two data sets where the first dataset contains probabilities. The second data …
add a command and all generated variables and data lost.rename __merge __merge1 /* rename previous merge commands in order to merge tax+financial data with …
Subscribe to:
Post Comments (Atom)
0 Response to Generate and Replace
Post a Comment