Hello,
I want to fill missing strings by using the last observation.
For values I can do it with a command like
However, if i want to do it with strings, Stata reports r(109) - type mismatch. Hence my question is how to do the filling with strings in a dataset like this:
E.g. I want to fill the countryname for the 2-4 line with "Dominican Republic" from line 1, lines 6-8 with line 5, etc. Thanks you for your help in advance!
I want to fill missing strings by using the last observation.
For values I can do it with a command like
Code:
replace dummy=dummy[_n-1] if dummy==.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str22 countryname str3 ifs float q_date_all "Dominican Republic" "DOM" 212 "" "" 213 "" "" 214 "" "" 215 "Dominican Republic" "DOM" 216 "" "" 217 "" "" 218 "" "" 219 "Ecuador" "ECU" 60 "" "" 61 "" "" 62 "" "" 63 "Ecuador" "ECU" 64 end format %tq q_date_all
E.g. I want to fill the countryname for the 2-4 line with "Dominican Republic" from line 1, lines 6-8 with line 5, etc. Thanks you for your help in advance!
Comment