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
Change the lenght of a stringHi, I have a dataset where the variable id is stored as a str9, although this id has only 8 charact…
Can I use multiple imputed data in a principle component analysis if my data are not normally distributed?Is it possible to use multiple imputed data in a principle component analysis if my data are not nor…
Adding post-estimation results in -esttab- table by adding more columns to e(b) and columns and rows to e(V)Dear Statalist, I want to put -nlcom- results in esttab table and these -nlcom- results are treated…
Should I use a heckman selection model when extracting a subset of my data for analysis?This is a new topic for me, so pardon my basic understanding of the heckman model. In fact, it's pos…
Forest plot of sub-groups and testing for interactionDear Statlist, I'm trying to generate a forest plot to demonstrate how various parameters from my r…
Subscribe to:
Post Comments (Atom)
0 Response to Creating tempfiles in a forvalue loop
Post a Comment