Date: Mon, 12 Apr 2010 12:13:34 -0700
Reply-To: "Schwarz, Barry A" <barry.a.schwarz@BOEING.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Schwarz, Barry A" <barry.a.schwarz@BOEING.COM>
Subject: Re: Reading a CSV format date & time into SAS
In-Reply-To: <26DF7D5381294184A8E970B421F7C668@Garage1>
Content-Type: text/plain; charset="us-ascii"
Since all the standard datetime formats seem to require character months instead of numeric, I see only two choices:
Read the data with a character informat and then use something like
dt = dhms(input(substr(data,1,10),date10.),
0,0,
input(substr(data,12,5),time5.));
to construct the datetime value
Use proc format to build you own informat to accept the data directly into a datetime variable.
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of HealthMaps
Sent: Saturday, April 10, 2010 7:14 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Reading a CSV format date & time into SAS
Barry,
Either. I am happy with a date time variable or separate date and time
variable. I know how to go back and forth. (I think) I will be using the
combined to calculate a time interval, this is traffic collision data and I
want time to the hospital from various time parameters of a car crash (when
the police arrived, when EMTs showed up, etc) and separately because I need
to determine what part of the day the time value refers to (after midnight,
8am-noon, etc) and also the date to look at seasonality.
And of course, guess I am a bit too lazy, I can read it in as a character
variable and since the time and date parts are the same length I can use
SUBSTR to suck the date and time part out and then convert the resulting
strings to date and time. I was thinking that there would be a one step
solution with some function I could not find/don't know about (yet).
How would you do it?
Thanks for your help.
Dick
-----Original Message-----
From: Schwarz, Barry A [mailto:barry.a.schwarz@boeing.com]
Sent: Friday, April 09, 2010 3:15 PM
To: healthmaps@COMCAST.NET; SAS-L@LISTSERV.UGA.EDU
Subject: RE: Reading a CSV format date & time into SAS
You can always read it as a character variable (the imbedded space is
obviously not a problem since you can handle Porky Pig).
So tell us what you really want. Do you want the result to be a datetime
variable or a date variable and a separate time variable?
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
HealthMaps
Sent: Friday, April 09, 2010 2:20 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Reading a CSV format date & time into SAS
In a large dataset in CSV format (million records) I have discovered date
and time formats (just a space between the date and time) for example: date
is year-month-day time is 24 hour
2008-01-11 07:06
a typical sequence of the CSV data is
0,1,1,,,,,0,2,Donald,Duck,3.14159,0,1,,1,1,2008-01-11 07:06,Porky
Pig,1,,3,2,1,2006-11-02 19:22,0,0,0,0,1 etc
I know how to handle the rest of it, but what is the correct way to read
this in?
|