|  |  | 
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: RE: puzzling "missing" before and after "gen newvar = mdy(a, b, c)"
| From | Michael McCulloch <[email protected]> | 
| To | [email protected] | 
| Subject | Re: st: RE: puzzling "missing" before and after "gen newvar = mdy(a, b, c)" | 
| Date | Fri, 12 Jan 2007 13:58:14 -0800 | 
Thanks Nick; using -todate-, now the missing values are no longer generated.
. todate datedx , gen(datedx2) pattern(yyyymmdd)
. format datedx2 %d
Out of curiosity, I looked back at my previous method, and found that there 
were day and month ==99.
. summarize dx??1
    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       dxyr1 |     26806    1990.195    1.958295       1987       1993
       dxmo1 |     26806    7.269828    9.244575          1         99
       dxda1 |     26806    17.66037    15.60529          1         99
I appreciate your help.
Michael
At 01:42 PM 1/11/2007, you wrote:
summarize dx??1
to see which of the days, months, years variables are
out of range.
Anyway, why are you doing it this way? Only a few days ago
a thread you started thrashed out the fact that -todate- from SSC
should be able to do it in one line.
todate datedx, pattern(yyyymmdd) format(%d) gen(datedx1)
Nick
[email protected]
Michael McCulloch
> I've converted a string date (yyyymmdd) to Stata format, using:
>
> . * convert datedx to Stata format
> . tostring datedx, replace
>          datedx was double now str8
> . generate str4 dxyr1= substr(datedx,1,4)
> . generate str2 dxmo1 = substr(datedx,5,6)
> . generate str2 dxda1 = substr(datedx,7,8)
> . destring dx*, replace
>          dxyr1 has all characters numeric; replaced as int
>          dxmo1 has all characters numeric; replaced as byte
>          dxda1 has all characters numeric; replaced as byte
> . gen datedx1 = mdy(dxmo1, dxda1, dxyr1)
>          (387 missing values generated)
> . format datedx1 %d
>
> However, search for missing values before & after my commands
> yields nothing:
> . list datedx if missing(datedx) in 1/10
>
> Where might the missing 387 values have originated?
*
*   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/
Best wishes,
Michael
____________________________________
Michael McCulloch
Pine Street Clinic
Pine Street Foundation
124 Pine Street, San Anselmo, CA 94960-2674
tel     415.407.1357
fax     415.485.1065
email:  [email protected]
web:    www.pinest.org
        www.pinestreetfoundation.org
        www.medepi.net/meta
*
*   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/