Date: Sat, 10 Apr 2010 15:00:05 -0500
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: Reading a CSV format date & time into SAS
In-Reply-To: <26DF7D5381294184A8E970B421F7C668@Garage1>
Content-Type: text/plain; charset=ISO-8859-1
YMDDTTM. Informat.....
data _null_;
infile datalines dsd;
input (16*d)(:$1.) dt :ymddttm16.;
put dt=datetime.;
datalines;
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
;;;;
run;
On 4/10/10, HealthMaps <healthmaps@comcast.net> wrote:
> 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?
>
|