Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: RE: Reshape question (managing elapsed date)

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: Reshape question (managing elapsed date)
Date   Fri, 24 Oct 2003 18:19:43 +0100

I thought I understood this problem, 
and that it was a problem to do with 
monthly dates. 

Now it seems that these dates are daily dates, but 
that you want a tabulation by months. 

So my latest suggestion is 

expand 2
bysort serial : replace bclmstdt = bclmeddt if _n == 2 
gen mbclmstdt = month(bclmstdt) 
tsset serial mbclmstdt 
tab serial mbclmstdt 

That way you are assured exact months, although
the tabulation ignores day within month. 

Note that you will get a display of 2 in the table
if a person starts and ends within the same month. 

[email protected] 

> -----Original Message-----
 Joao Pedro W. de Azevedo
> Many thanks for your help.
> I have another question.
> The format of my date variable is elapsed date.  
> As an approximation I'm using 30.5 as my average month, 
> however I would like
> to be more precise.
> I would like to know if any one could suggest me any 
> procedure to increase
> the acuracy of this process. 
> . preserve
> . gen diff = 1+round((bclmeddt- bclmstdt)/30.5) 
> . expand diff
> . bysort serial : replace bclmsdt = bclmsdt[_n-1] + 1 if _n > 1
> . tab serial bclmsdt
> . save expanded
> . restore

*   For searches and help try:

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