[prev in list] [next in list] [prev in thread] [next in thread]
List: sas-l
Subject: Re: extract data from text field
From: Howard Schreier <Howard_Schreier () ITA ! DOC ! GOV>
Date: 2004-02-27 21:50:38
[Download RAW message or body]
Assuming that the file is a SAS dataset named PASSED, try this:
data need;
keep id sasdate;
infile cards dlm=', @';
if _n_=1 then input @@;
set passed;
_infile_ = date;
input @1 mon $ day year $ @@;
sasdate = input(compress(put(day,z2.) || mon || year),date9.);
format sasdate date9.;
cards;
_INFILE_ magic being used
;
The key is the multiple delimiter values on the INFILE statement.
The inline data (CARDS;) is just a device to provide a buffer for the INPUT
statement to use.
If the given file is an external file, it's simpler. Something like:
data need;
keep id sasdate;
infile whatever dlm=', @';
input id mon $ day year $;
sasdate = input(compress(put(day,z2.) || mon || year),date9.);
format sasdate date9.;
run;
On Fri, 27 Feb 2004 14:40:52 -0600, Laurel Copeland
<Laurel.Copeland@MED.VA.GOV> wrote:
>Hello.
>I have been passed a file that contains the date in a text field that looks
>like this:
>
>ID DATE
>11 APR 12,2002@15:00
>14 SEP 16,2002@11:35:57
>14 OCT 25,2002@11:44
>16 APR 30,2002@09:45
>16 APR 8,2002@12:30:18
>16 APR 9,2002@16:00
>
>There is no leading zero on days that are 1-9, there is always 1 space
>between month and day, and there is a comma between day and year. The
month
>is always 3 characters text. I don't need the times (as far as I know).
>
>I can't figure out how to get the date out. I would very happy for your
>thoughts on this.
>Thanks,
>Laurel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic