Hey guys, sorry if this is long, but I'm entirely new to stata. I also apologise if I don't use the right terminology or formatting for this post.
I'm working with Labour force surveys for 2019-2022 to run a comparative analysis between 2 sectors Health and Accommodation. This is what my data set looks like:
naics_21 lfsstat atothrs hrlyearn date
Health Employed 40 21.65 2019m1
Accom unemployed 42 20 2019m3
Health Employed 34 24.56 2020m7
Health Employed 20 . 2020m9
Health unEmployed 40 . 2021m1
Accom Employed 35 28.38 2021m8
Health unEmployed 55 24.05 2021m9
Health Employed 40 15 2021m12
Accom Employed 33 8.33 2022m1
Health Employed 30 17.85 2022m3
All of the variables are numeric( Health=17, Accom=19, employed=1, etc)
I need to define a variable that calculates total number of employed or unemployed or unemployment rate(unemployed/employed+unemployed) by sector and month .
Eg: Health 2019m01 5%; Accommodation 2019m01 15%
Health 2019m02 7%; Accommodation 2019m02 25%......
Health 2022m12 3%; Accommodation 2022m12 5%
I've already tried a few things from 'count if' command to foreach loops with increment counters, but nothing has been working. The Count if command shows me the numbers I need, but I have no idea how to assign it to a variable.
In essence I'm trying to obtain 2 time series graphs for each sector: one for atothrs with respect to date, and one for unemployment rate with respect to date.
Can someone please help me out here/ point me in the right direction?
This is my code so far:
use "lfs_2019 (1).dta"
append using "lfs_2020.dta"
append using "lfs_2021.dta"
append using "lfs_2022.dta"
keep if !missing(survyear, survmnth)
gen date= ym(survyear, survmnth)
format date %tm
sort date
keep date naics_21 lfsstat hrlyearn atothrs
drop if lfsstat==4
keep if naics_21 ==17| naics_21==19
egen hrswrked =sum(atothrs), by(naics_21 date)
egen wage=mean(hrlyearn), by(naics_21 date)
line hrswrked date, by(naics_21)
(I was able to get one of my required time series, but is there anyway to have both these lines on the same graph?)
Array
0 Response to Obtaining time series graphs
Post a Comment