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
Related Posts with Obtaining time series graphs
DRAMATIC CHANGES IN HAZARD RATIO and MORTALITY RATIOHi Everyone, Below is an example of data from the survival analysis. The total duration of follow…
Reproducing Cochrane meta-analysis in -meta-I'm preparing some teaching material on meta-analysis. I have some neat examples from Cochrane revie…
Panel data, time series: creating variable after specific entryHi all, I'm trying to create variable that is equal to the date at which the first plane is produce…
Restricting the survival analysis to first five years since diagnosisHi Everyone, Below is an example of data from the survival analysis. The total duration of follow…
Survival analysis setup.I'm having a problem setting my data for a survival analysis. I am using STATA 16.0 for windows. I…
Subscribe to:
Post Comments (Atom)
0 Response to Obtaining time series graphs
Post a Comment