Dear all,
I have a long occupational dataset with several rows of observations for each person representing different jobs they have worked over their lifetime. Each person is identified with a unique ID number.
I have start year and finish year variables for each job, but I need to create start month and finish month variables to get a more specific exposure duration.
I have decided that depending on the start and finish years of each consecutive job, the start month will be assigned as either June/January, and the finish month assigned as July/December.
The rules are as follows:
- If the finish year of the previous job is the same as the start year of the subsequent job, the stop/start months for those jobs will be assigned as June/July.
- If the finish year of the previous job is the year before the start year of the next job, the stop/start months for those jobs will be assigned as December/January.
I am trying to write some code in STATA.
I have tried to create a loop to make the code run through each unique ID number, and then run through each individual row for that ID number. However, it currently doesn´t work and I am not sure how to write the "if" command to assign the correct start/finish months from the multiple rows of data.
Any help would be greatly appreciated!
Related Posts with Stata Loops
How to tell Stata not to ignore missing values in bysort: egen mean commandDear Stata-Listers, I am posting a question for the first time, so I hope I'm doing it correctly. …
I'm converting a date but the new date variable is all missing valuesI'm using Stata 14.2. i have a dataset with dates in a string variable e.g. 01-Apr-2018. I have used…
Estimating Modified Jones Model ,No final values generated for Jones modelHi, I am trying to estimate the discretionary accruals through the modified Jones model in Stata. T…
Difference between areg and xtset for firmxyear fixed effectDear all, I would like to find the effect of bank liquidity risk (my independent variable) on loan…
How to deal with I(1) and I(0) variables in econometric analysisDear Users, I am working on a balanced panel with 50 countries observed over 19 years. My main depe…
Subscribe to:
Post Comments (Atom)
0 Response to Stata Loops
Post a Comment