Background:
-I am a Stata novice/improver, I have learnt to import from excel, drop variables, re-shape data from long form to wide form, de-string numeric variables, and run metan and metareg.
-I am completing a meta-analysis where some outcomes are reported as times (e.g. time of sleep onset). I therefore have time variables which Stata interprets as strings (28 in total, including a mean and SD for an intervention group and a control group for each outcome).
I am hoping there is a way to change / replace / recode time variables (which are currently strings) so that each one retains the same name, but is recognised as a I time. I think I am missing something basic. To explain tat is below, I decided to use a naming convention so that I can stay orientated to my data - such that mean sleep onset time in the intervention group is named: Ix_SOT_M. The only way I have been change these from strings to times so far is with four steps for each variable as follows:
gen double temp = clock(Ix_SOT_M, "hm")
drop Ix_SOT_M
rename temp Ix_SOT_M
format Ix_SOT_M %tc
I tried but was incorrect with a few options including:
. replace Ix_SOT_M = clock(Ix_SOT_M, "hm")
type mismatch
r(109);
I am hoping there is a way to do this in fewer steps ?or even for all 28 variables using one process?
If this is the most efficient way in terms of commands does anyone have any advice on how to best generate lots of similar commands but with a different variable name in each one, and how to then efficiently run these?
Advice much appreciated.
Sophie
-I am a Stata novice/improver, I have learnt to import from excel, drop variables, re-shape data from long form to wide form, de-string numeric variables, and run metan and metareg.
-I am completing a meta-analysis where some outcomes are reported as times (e.g. time of sleep onset). I therefore have time variables which Stata interprets as strings (28 in total, including a mean and SD for an intervention group and a control group for each outcome).
I am hoping there is a way to change / replace / recode time variables (which are currently strings) so that each one retains the same name, but is recognised as a I time. I think I am missing something basic. To explain tat is below, I decided to use a naming convention so that I can stay orientated to my data - such that mean sleep onset time in the intervention group is named: Ix_SOT_M. The only way I have been change these from strings to times so far is with four steps for each variable as follows:
gen double temp = clock(Ix_SOT_M, "hm")
drop Ix_SOT_M
rename temp Ix_SOT_M
format Ix_SOT_M %tc
I tried but was incorrect with a few options including:
. replace Ix_SOT_M = clock(Ix_SOT_M, "hm")
type mismatch
r(109);
I am hoping there is a way to do this in fewer steps ?or even for all 28 variables using one process?
If this is the most efficient way in terms of commands does anyone have any advice on how to best generate lots of similar commands but with a different variable name in each one, and how to then efficiently run these?
Advice much appreciated.
Sophie
Comment