Dear Statalisters,
say I have the following variable names:
My broader goal is to combine information from those variables with the same prefix. More specifically, in the case of the example above, I want to create two variables
and afterwards iterate over all variables with the corresponding prefix to fill up the missings.
For this to work, I need Stata to
I'm unable to identify these prefixes manually given that the number of variables is large and the procedure has to be done for several datasets.
Any hint is greatly appreciated!
say I have the following variable names:
Code:
child_id_kp child_id_ka child_id_ng month_gh month_ka month_ng
Code:
gen child_id = . gen month = .
For this to work, I need Stata to
- identify prefixes that occur multiple times
- store all variables with the corresponding prefix in a local
Code:
local child_id child_id_kp child_id_ka child_id_ng local month month_gh month_ka month_ng
Any hint is greatly appreciated!
Comment