Hello Stata experts,
I am trying to perform a log function within loops, but it gives me errors that I do not know how to fix it. Your help would be much appreciated. Thanks!
This is the code that I am running:
This code gives me the r(198) error, but I already created the "gwgkg" as a continuous variable and I do not know why the plus (+) sign got mixed up with the variable name.
I tried using parenthesis to make the variable name "gwgkg" and it does not work either.
Now the error is:
unknown function ()
r(133);
Thank you!
I am trying to perform a log function within loops, but it gives me errors that I do not know how to fix it. Your help would be much appreciated. Thanks!
This is the code that I am running:
Code:
forvalues i = 6/40 { forvalues j = 1/6{ foreach k in lmn if gestage2==`i' & bmiprepregcat6==`j'{ foreach l in lsd if gestage2==`i' & bmiprepregcat6==`j'{ replace zscore = (log(gwgkg +`c')-`k')/`l' if gestage2==`i' & bmiprepregcat6==1 } } } }
gwgkg+ invalid name
r(198);
r(198);
Code:
forvalues i = 6/40 { forvalues j = 1/6{ foreach k in lmn if gestage2==`i' & bmiprepregcat6==`j'{ foreach l in lsd if gestage2==`i' & bmiprepregcat6==`j'{ replace zscore = ((log(gwgkg) +`c')-`k')/`l' if gestage2==`i' & bmiprepregcat6==1 } } } }
unknown function ()
r(133);
Comment