Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str1 ID float(phase HasMembership) "A" 1 0 "A" 3 1 "B" 1 1 "B" 2 0 "B" 3 1 "C" 1 0 "C" 2 1 "C" 3 1 "D" 2 1 "D" 3 0 "E" 1 1 "E" 3 0 "F" 1 1 "F" 3 0 end
The problem with my actual full fledged dataset is that there are individuals who don't always have consecutive phases. For example, in the given dataex, individual A has observations only in phase 1 and phase 3, we don't know anything about him in phase 2. Therefore with the solution code given in my previous post, the generated variables could not capture anything for individual A. It is my mistake that when I provided a dummy representative dataset, I made it balanced instead of unbalanced.
To counter this problem, is there any code or solution in stata by which I can generate dummy observations for individuals whose observations are not in every phase? And of course the values of Membership for those dummy variables would be the missing value. This is only to counter the problem that the solutions won't work for non consecutive periods. Hence since individual A has no observations in phase 2, his p2_p3 variable is missing. But I still want to capture the change that some time between phase 1 and phase 3, he did gain membership.
Otherwise if there is any other viable solution, I would be grateful to know.
EDIT: Thanks to Mr. Schechter for pointing out the mistake in the dataex, I have updated it
0 Response to Generating dummy observations to balance a panel
Post a Comment