Date: Wed, 21 Jun 2006 17:37:27 -0400
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: sas date time problem
On Tue, 20 Jun 2006 12:56:50 -0400, Ankur Arora <ankur.arora@NAGARRO.COM> wrote:
>Thanks very much for replying back ya we have a naming convention that
>time variable is always as the last variable
>naming convention for the data is
>STUDYID USUBJID DOMAIN BWSEQ BWGRPID BWTESTCD BWTEST BWORRES
> BWORRESU BWSTRESC BWSTRESN BWSTRESU
> BWBLFL BWSTDTC BWENDTC BWSTAT BWREASND
>DP1111 13 BW 34 BW Body Weight 266.4 g
> 266.4 266.4 g Y 2005-03-09T01:54:25
You have presented this sample, several times, and it raises questions,
since there appear to be 17 names but only 14 values. A better example would
also have fewer columns but more rows.
>In the second data the prefix "bw" changes to "ss"
>can we somehow have a command in proc import which changes the format of
>all the variables to character format
>so that date is read as it is
As far as I can tell, such an option does not exist. It seems like a good
idea, considering how often PROC IMPORT falls short of people's needs.
Getting everything in character would be sort of a lowest common
denominator, and a helpful basis for workarounds.
Here's my test:
put 'ID' '09'x 'date_time';
put 'AA' '09'x '2005-03-09T01:54:25';
*put 'AA' '09'x 'D2005-03-09T01:54:25';
*put 'AA' '09'x '09Mar2005 01:54:25';
PROC IMPORT OUT= WORK.TEST
It's ironic that if your layout for the date-time value were *less*
recognizable than it is, you would be better off. Move the asterisk so that
my second put statement is in effect, thus inserting a "D" before the date
subfield. Then PROC IMPORT preserves the whole field as a character variable.
As I said, I would stay away from PROC IMPORT and use a DATA step instead.
That's not hard if the columns are all of the same type and if width is not
an issue. Otherwise you need metadata.
Another solution is to use PROC IMPORT *and* a data step designed to pick up
just the date-time column, then merge the pieces.