LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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:

>hi > >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 > >first data >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:

data _null_; file 'c:\temp\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'; run;

PROC IMPORT OUT= WORK.TEST DATAFILE= "c:\temp\test" DBMS=TAB REPLACE; GETNAMES=YES; DATAROW=2; RUN;

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.

> >Thanks >Ankur


Back to: Top of message | Previous page | Main SAS-L page