Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: combining variables


From   Thomas Norris <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: combining variables
Date   Thu, 2 May 2013 13:32:14 +0000

Dear statalisters,

I am entering values for; l, m, s for males and females in my dataset. The values of l, m, s depend not only on sex but also on age at birth, for example, males of 32weeks would have l=0.95, m=1.8 and s=0.18, whereas females of the same age would have l=0.89, m=1.71 and s=0.187. 

I started generating the l,m,s scores for males at 32 weeks using 'gen l=0.95 if gest==32 & sex==0' 'gen m=1.80 if gest==32 & sex==0' 'gen s=0.180 if gest==32 & sex==0' 
and then for females at 32 weeks using gen 'l2=0.89 if gest==32 & sex==1' 'gen m2=1.71 if gest==32 & sex==1' 'gen s2=0.187 if gest==32 & sex==0'.

This is quite time consuming as I have to enter l,m,s scores for males and females for each week from 32-42. Is there a quicker way of entering these?

Furthermore, as you can see, if I continue until 42 weeks, I will have variables going from l-l22, m-m22 and s-s22. How can I combine these so I finish with only 1 variable for each?
I looked at the literature and thought -forvalues- might do this job, but I was unsuccessful.

Any help would be really appreciated,

Tom 


Tom Norris (PhD student)
Centre of Global Health and Human Development
School of Sport, Exercise and Health Sciences
Loughborough University
Loughborough
LE11 3TU


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index