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
classification of firms into groups based on some criterion Code: input str1 firm int year float(profits) "a" 2000 . "a" 2001 . "a" 2002 . "…
egenmore: filterMany thanks to Nick Cox for writing egenmore. Minor comment. I have two series, Y and X, from years …
date turns into missing values when I generate new variableHi All, I have date variable in this format (M/D/Y). I want to change it to a numeric format like 1…
Should I spend more time on improve my programming ability?I am a doctoral student.My major is applied econonmics.My main job is to analyze agricultural proble…
testing the economic significance of an interaction term of two categorical variablesHello everyone, I ran the following regression : xi: areg Y X1 X2 X1_X2 $x i.year, absorb(firm_id)…
Subscribe to:
Post Comments (Atom)
0 Response to Creating tempfiles in a forvalue loop
Post a Comment