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
Reshape using j varname string as variable name outputHi Statalists! Currently I am trying to reshape daily returns data for S&P500 listed companies …
Analyzing Multi response questionHi All, I am a beginner STATA user and I need help to solve the challenge I face: I have an example…
QP/LM not found in xtqptestDear all, I'm trying to apply the "xtqptest" by Born and Breitung in my Panel Data analysis. As sug…
Export misstable to LatexHi, What options are available for exporting Stata's misstable to Latex? This was asked six years …
scatterplot with text labels for y and x?Dear All, I'd like to have a figure like below (need not to be exactly the same). Array I make up …
Subscribe to:
Post Comments (Atom)
0 Response to Generate and Replace
Post a Comment