I have a dataset where I want to get the sample size for each race category by year and sector (occupation). My race variable name is wbho and the values are White (1), Black(2), Hispanic(3), Others(3). I wrote a forval loop to do this, but I can't save them as different tempfiles inside the loop (since the race variable name is the same for each collapse result). In the end, I want to append the 4 tempfiles. How can I do that? Here is my loop:
```
forval i=1/4 {
use ${data}wbho.dta, clear
gcollapse (count) wbho if wbho==`i', by (year docc03)
}
```
After each tempfile is saved, I was going to append like this:
```
use `part1', clear
append using `part2'
append using `part3'
append using `part4'
tempfile overall
save `overall'
```
Related Posts with Creating tempfiles in a forvalue loop
Fixed Effects: how to report in a tableHi all, I would like to ask a question, please, about how to report a fixed effects regression in a…
Difficulty with margins: Wald estimate discrepency between ivreg2 and marginsHello, I am trying to estimate the Wald estimand and calculate standard errors using margins and sue…
Prediction interval (not confidence interval) calculations for glm w/ robust VCE model?In reference to the two threads below, did anybody ever figure out how to get prediction intervals/i…
5*5 bivariate dependent sorting for portfolio creation Code: * Example generated by -dataex-. To install: ssc install dataex clear input str15 companies b…
Problem with Gen & string/numeric variable conversionDear forum members, I am new to Stata and having a problem that I can't seem to find a straightforw…
Subscribe to:
Post Comments (Atom)
0 Response to Creating tempfiles in a forvalue loop
Post a Comment