Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str22 uid double id "231598-231591-18432187" 1 "231598-231591-27755918" 2 "" 3 "231598-231591-18673626" 4 "231598-231591-27917427" 5 "" 6 "231598-231591-18619403" 7 "231598-231591-27611910" 8 "" 9 "231598-231591-18542583" 10 "231598-231591-27642617" 11 end
I attempted to solve this with the following code:
Code:
count local j = 1 gen pid = . forvalues i = 1/`r(N)'{ if uid != ""{ replace pid = `j' } else{ replace pid = 0 local `j' = `j'+1 } }
I would be grateful for advice on my coding error and suggestions for how to approach this problem.
Thank you,
Martyn
0 Response to Data restructuring
Post a Comment