I am trying to fill missing values between two markers (start marker and end marker).
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte epoch str8 activity 1 "" 2 "" 3 "sleep" 4 "" 5 "" 6 "" 7 "sleep" 8 "" 9 "work" 10 "" 11 "" 12 "" 13 "" 14 "" 15 "work" 16 "" 17 "exercise" 18 "" 19 "exercise" 20 "" end
So I want to get to this:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte epoch str8 activity 1 "" 2 "" 3 "sleep" 4 "sleep" 5 "sleep" 6 "sleep" 7 "sleep" 8 "" 9 "work" 10 "work" 11 "work" 12 "work" 13 "work" 14 "work" 15 "work" 16 "" 17 "exercise" 18 "exercise" 19 "exercise" 20 "" end
This:
Code:
replace activity=activity[_n-1] if activity=="" // fill down
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte epoch str8 activity 1 "" 2 "" 3 "sleep" 4 "sleep" 5 "sleep" 6 "sleep" 7 "sleep" 8 "sleep" 9 "work" 10 "work" 11 "work" 12 "work" 13 "work" 14 "work" 15 "work" 16 "work" 17 "exercise" 18 "exercise" 19 "exercise" 20 "exercise" end
I am looking forward to your solutions.
Thanks so much.
Best regards,
Rob
0 Response to Filling missing values between two markers
Post a Comment