Hi, I have a problem in Stata and I hope that somebody can help me.
My panel dataset looks the following:
I want to create a new variable that sums up the value of id==33 everytime the id has a 1.
For example:
I tried a foreach loop, but I did not figure out how correctly reference to the id==33 data. I know it would be easier if I would run the id==33 as a seperate variable, but since I have multiple Input parameters it becomes a mess to have once a code variable that identifies whether the input is relevant for the id and the value of the input parameter in the second variable itself (I have about 100 Input variables).
I hope somebody can help me.
My panel dataset looks the following:
Code:
Date ID Input1 Input2 13880 4 1 . 13880 5 1 . 13880 6 . . 13880 7 1 1 13880 8 . . 13880 9 . . 13880 10 . 1 13880 32 . . 13880 33 8000 4500
For example:
Code:
Date ID Sum(Variable I would like to create) 13880 4 8000 13880 7 12500 13880 8 0
I hope somebody can help me.