I am trying to agregate variables (part of different random experiments) in one unique variable covering all the sample (group A+group B+ group C, etc). I have to do this for a lot of variables, so I was trying to create a "loop". Variables are coded like missing_wave2question1a, missing_wave2question1b, missing_wave3question1c, etc.
What I want to do is to create a "loop" to perform the same as:
egen missing_wave3question1= rowtotal(missing_wave2question1a missing_wave2question1b missing_wave2question1c (...)).-> I use egen rowtotal to avoid missings.
I have tryied to create a macro like:
local letter a b c (...)
egen missing_wave3question1= rowtotal(missing_wave2question1`letters') -> do not perform correctly
or to use :
egen missing_wave3question1= rowtotal(missing_wave2question1*)-> uses too many variables (10, 11, 12, etc)
I know that this may be an easy task, but I am stuck. If I can do this then I would be able to crate a larger loop for all the variables with a few lines of code, but I need to solve this "letters issue".
Thanks!
What I want to do is to create a "loop" to perform the same as:
egen missing_wave3question1= rowtotal(missing_wave2question1a missing_wave2question1b missing_wave2question1c (...)).-> I use egen rowtotal to avoid missings.
I have tryied to create a macro like:
local letter a b c (...)
egen missing_wave3question1= rowtotal(missing_wave2question1`letters') -> do not perform correctly
or to use :
egen missing_wave3question1= rowtotal(missing_wave2question1*)-> uses too many variables (10, 11, 12, etc)
I know that this may be an easy task, but I am stuck. If I can do this then I would be able to crate a larger loop for all the variables with a few lines of code, but I need to solve this "letters issue".
Thanks!
Comment