Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: cumulate values of X whithin group


From   Robert A Yaffee <[email protected]>
To   [email protected]
Subject   Re: st: cumulate values of X whithin group
Date   Mon, 07 May 2007 22:16:50 -0400

Sara,
 You're quite welcome.
   Robert

Robert A. Yaffee, Ph.D.
Research Professor
Shirley M. Ehrenkranz
School of Social Work
New York University

home address:
Apt 19-W
2100 Linwood Ave.
Fort Lee, NJ
07024-3171
Phone: 201-242-3824
Fax: 201-242-3825
[email protected]

----- Original Message -----
From: sara borelli <[email protected]>
Date: Monday, May 7, 2007 10:01 am
Subject: Re: st: cumulate values of X whithin group
To: [email protected]


> thank you very much!
> sara
> 
> --- Robert A Yaffee <[email protected]> ha scritto:
> 
> > Sara,
> >   Use a generate rather than a replace statement in
> > the last line.
> > 
> > 
> > gen member=substr(var1,1,6)
> > gen oldate = substr(var1,10,14)
> > gen x = substr(var1,29,4)
> > drop if _n ==1
> > destring member, replace
> > destring x, replace
> > drop if _n == 5
> > drop var1
> > gen date=date(oldate,"md20y")
> > format date %td
> > gen cumx = sum(x)- x
> > 
> > Cheers,
> >     Robert
> > 
> > 
> > 
> > Robert A. Yaffee, Ph.D.
> > Research Professor
> > Shirley M. Ehrenkranz
> > School of Social Work
> > New York University
> > 
> > home address:
> > Apt 19-W
> > 2100 Linwood Ave.
> > Fort Lee, NJ
> > 07024-3171
> > Phone: 201-242-3824
> > Fax: 201-242-3825
> > [email protected]
> > 
> > ----- Original Message -----
> > From: sara borelli <[email protected]>
> > Date: Saturday, May 5, 2007 2:45 pm
> > Subject: st: cumulate values of X whithin group
> > To: [email protected]
> > 
> > 
> > > Dear Statalist members,
> > > 
> > > I have the following question:
> > > 
> > > 
> > > Member       Date              X
> > > 133          04-05-2000        1
> > > 133          04-07-2000        4
> > > 133          05-06-2000        2
> > > 133          07-10-2000        3
> > > 
> > > 145          06-05-2000        5
> > > 145          06-15-2000       5
> > > 145          08-05-2000       0
> > > 145          10-20-2000       2
> > > 145         11-05-2000       4
> > > 145          12-03-2000      6
> > > 
> > > Within each member, I need to create a variable
> > that
> > > cumulates the values of X up to the date of the
> > > current observation excluding the value of X of
> > the
> > > current observation, that is I need to create Xnew
> > > such that:
> > > 
> > > Member   Date                   X    Xnew
> > > 133          04-05-2000        1     0
> > > 133          04-07-2000        4     1
> > > 133          05-06-2000        2      5
> > > 133          07-10-2000        3      7
> > > 
> > > 145          06-05-2000        5      0
> > > 145          06-15-2000       5       5  
> > > 145          08-05-2000       0       10
> > > 145          10-20-2000       2       10
> > > 145         11-05-2000       4        12
> > > 145          12-03-2000      6        16
> > > 
> > > any help would be really appreciated
> > > [email protected]
> > > 
> > > 
> > > 
> > >       ___________________________________ 
> > > L'email della prossima generazione? Puoi averla
> > con la nuova Yahoo! 
> > > Mail: http://it.docs.yahoo.com/nowyoucan.html
> > > *
> > > *   For searches and help try:
> > > *  
> > http://www.stata.com/support/faqs/res/findit.html
> > > *   http://www.stata.com/support/statalist/faq
> > > *   http://www.ats.ucla.edu/stat/stata/
> > *
> > *   For searches and help try:
> > *  
> > http://www.stata.com/support/faqs/res/findit.html
> > *   http://www.stata.com/support/statalist/faq
> > *   http://www.ats.ucla.edu/stat/stata/
> > 
> 
> 
> 
> 	
> 
> 	
>         	
> ___________________________________ 
> L'email della prossima generazione? Puoi averla con la nuova Yahoo! 
> Mail: 
> http://it.docs.yahoo.com/nowyoucan.html
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index