Hi everyone,
I'm having a long panel data set with 1250 individuals (identified by case) and information about their entrance into the labor market. The variable shown below "nummer_eintritt" shows, if it was the first, second, third, etc. entrance. I have a third variable "SES_" (I cannot display due to data privacy) that I now want to analyse.
For each individual, I want to generate a new variable that contains the value of SES_[_n-1] if nummer_eintritt[_n]==1, if the SES_[_n-1] is not missing. If it is missing, it should display the value of SES_ for _n-2 and so on.
I tried to get it by putting lots of conditions together, but it would end in a very high number of conditions because sometimes you have to go back 20 observations to find a non missing value.
Could you please help me on that?
Thank you and best regards
Marie
clear
input long case float nummer_eintritt
681 0
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 1
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
681 .
end
[/CODE]
Related Posts with Identifying first non-missing value based on another variable
Jackknife for xtpcseHi, I am trying to conduct a Jackknife estimation. The following command is able to be executed, e…
Error Correction Model (ECM) for panel dataDear all, I want to use an ECM model to estimate the short-term elasticity. I have a panel data and…
xtptqtest error: ue: At least one panel is too shortDear Community, In order to test for auto correlation in the error term of my dynamic panel regress…
Brant test assumptions Hello community, I wanted to ask about the assumption of proportional odds and the Brant test. i ha…
Differences between value-weighted portfolio regression and portfolio regression with aweight based on MCAPDear Statalists, I have done a quintile portfolio analysis and there is a declining pattern of equa…
Subscribe to:
Post Comments (Atom)
0 Response to Identifying first non-missing value based on another variable
Post a Comment