Code:
* Example generated by -dataex-. For more info, type help dataex clear input float person_id str10 income 1 "10, 20, 50" 2 "35, 20" 3 "" 4 "40" 5 "34, 24" end
person_id | income |
1 | 10 |
1 | 20 |
1 | 50 |
2 | 35 |
2 | 20 |
4 | 40 |
5 | 34 |
5 | 24 |
Typically, I would run
Code:
split income, parse(,) generate(inc) destring drop income reshape long inc, i(person_id) j(obs_id) drop if inc == . drop obs_id
For example, can I directly split my income values into rows? Or, is there a way in which I can ignore missing values when doing reshape? In my full dataset, most observations have only a few values in the income column, so that inc200 is almost all missing values. So if there was some way to preemptively drop them during the reshape, I think that could work as well.
Open to any other suggestions! Thanks everyone.
0 Response to Alternatives to using split and then reshape long?
Post a Comment