This is what I Currently Have
With this code, this is what i get.
But this is what I want and I can't figure out how.
besides all of this, i have different zones (zone1 zone2 zone3) e.g city, town, region, whatever.
so my code to get the latter table it's something like this, and i would like to know if it's fine (continuing the previous code)
Any help? hope I made my self clear.
Cheers!
| unemployment | period |
| x | 1 |
| y | 2 |
| z | 3 |
| w | 4 |
| t | 5 |
Code:
levelsof period, local(levels)
foreach i of local levels {
gen unemployment`i'=unemployment if period==`i'
}
| unemployment1 | unemployment2 | unemployment3 | unemployment4 | unemployment5 | period |
| x | . | . | . | . | 1 |
| . | y | . | . | . | 2 |
| . | . | z | . | 3 | |
| . | . | w | . | 4 | |
| . | . | . | . | t | 5 |
| unemployment1 | unemployment2 | unemployment3 | unemployment4 | unemployment5 | period |
| x | y | z | w | t | 1 |
| x | y | z | w | t | 2 |
| x | y | z | w | t | 3 |
| x | y | z | w | t | 4 |
| x | y | z | w | t | 5 |
so my code to get the latter table it's something like this, and i would like to know if it's fine (continuing the previous code)
Code:
levelsof period, local(levels)
foreach i of local levels {
gen unemployment`i'=unemployment if period==`i', by(period zone1 zone2 zone3)
gen unemployment`i'mean=mean(unemployment), by(period zone1 zone2 zone3)
replace unemployment`i'=unemployment`i'mean if unemployment==.
drop unemployment`i'mean
}
Any help? hope I made my self clear.
Cheers!

Comment