Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: converting SAS file to stata using stat transfer-date and time variables


From   wgould@stata.com (William Gould, StataCorp LP)
From   Leny Mathew <lenymathewc@gmail.com> writes
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: converting SAS file to stata using stat transfer-date and time variables
Date   Mon, 20 Dec 2010 11:09:50 -0600

> I'm trying to convert a SAS file (V 9.1) with date and time variables
> (separate) into stata and I'm using stat transfer (version 8) for
> this. During the conversion, the date variable comes across fine, but
> all the time variable values are between 0 and 1. stat transfer reads
> the SAS file without any problem, it looks fine in the viewer and it
> converts into excel without any problem. I didn't have to format the
> date variable within stata, so I'm assuming that I don't have to do
> any formatting for the time variable either. Has anyone had this issue
> before?

This should be easy because SAS and Stata save times in similar ways. 
Stata stores times as microseconds since 01jan1960; SAS as seconds. Thus, 
the transormation is

        . gen double stata_time = sas_time*1000
        . format stata_time %tc

Be sure that the original SAS time is recorded as a double.

Leny wrote "all the time variable values are between 0 and 1". I'm assuming
they are actually very large numbers and Leny didn't notice the e+## on 
the end.  If the numbers really are between 0 and 1, I don't think they 
are SAS time values.

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


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index