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 (February 2004, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 6 Feb 2004 13:02:53 -0500
Reply-To:     Bruce Johnson <bjohnson@SOLUCIENT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Bruce Johnson <bjohnson@SOLUCIENT.COM>
Subject:      Re: reading delimited data
Comments: To: Karen Olson <karen.olson@TCH.HARVARD.EDU>
Content-Type: text/plain; charset="us-ascii"

Karen,

To read the date fields, you need to add the colon : modifier..

data TEMP; length id $10. vdate 8. timetext $10. ddate 8. dtimetext $10. gender $1. ageyears 8.; infile 'TEMP.TXT' DSD delimiter='|' lrecl=1000 /*to avoid SAS cutting off prematurely*/ TRUNCOVER; input id $ vdate:yymmdd10. timetext $ ddate:yymmdd10. dtimetext $ gender $ ageyears ; format vdate ddate mmddyy10.; run; ________________________________ Bruce A. Johnson bjohnson@solucient.com

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Karen Olson Sent: Friday, February 06, 2004 12:00 PM To: SAS-L@LISTSERV.UGA.EDU Subject: reading delimited data

I have a delimited data file (delimited with |) that contains id, date, time, another date, another time, gender, and age.

I tried to read it with the following code:

data TEMP; length id $10. vdate 8. timetext $10. ddate 8. dtimetext $10. gender $1. ageyears 8.; infile 'TEMP.TXT' DSD delimiter='7C'x TRUNCOVER; input id $ vdate yymmdd10. timetext $ ddate yymmdd10. dtimetext $ gender $ ageyears ; format vdate ddate mmddyy10.; run;

However, I am not reading the data correctly and am having the most trouble reading the time variables.

What am I doing wrong?

Thanks,

Karen Olson Children's Hospital Boston karen.olson@tch.harvard.edu

-------------------------------- This is my sample data file: -------------------------------- 2y3034821c|2000/07/05|03:05 AM|2000/03/29|11:52 PM|M|49 72db1acd0f|2000/12/16|11:03 AM|||M| bb4e2a0718|2000/07/28||||M|48 6d59ff5c05|2000/02/10|11:13 PM|||F|37 ff1361cc92|2000/09/25|01:16 AM|||M|51 4cbc8e3bcc|||||M|51 3a30f0c61c|2000/03/29|04:37 PM|||| f7331c4b6e|2000/12/27|03:16 PM|||F|47 d5f747e0dd|2000/08/09|10:00 AM|||F|47 077739b87d|2000/12/18|04:55 PM|||F|57 4ff29e7e20|2000/12/17|00:12 AM||||68 nf8ss7f4db|2000/03/28|03:37 AM|||F|59 a118a49ba7|2000/06/14|09:02 PM|||F|57 6780 77b80|2000/07/10|07:37 PM|||F|57 nhk034857b|2000/05/08|03:37 PM|||M|26

-------------------------------- This is what my code yields: -------------------------------- Obs id vdate timetext ddate dtimetext gender ageyears

1 2y3034821c 07/05/2000 . 000/03/29 1 . 2 72db1acd0f 12/16/2000 . M . 3 bb4e2a0718 07/28/2000 . . 4 6d59ff5c05 02/10/2000 . F 37 5 ff1361cc92 09/25/2000 . M 51 6 4cbc8e3bcc . . . 7 3a30f0c61c 03/29/2000 . . 8 f7331c4b6e 12/27/2000 . F 47 9 d5f747e0dd 08/09/2000 . F 47 10 077739b87d 12/18/2000 . F 57 11 4ff29e7e20 12/17/2000 . 68 12 nf8ss7f4db 03/28/2000 . F 59 13 a118a49ba7 06/14/2000 . F 57 14 6780 77b80 07/10/2000 . F 57 15 nhk034857b 05/08/2002 . M 26 This message is a private communication. It may contain information that is confidential and legally protected from disclosure. If you are not an intended recipient, please do not read, copy or use this message or any attachments, and do not disclose them to others. Please notify the sender of the delivery error by replying to this message, and then delete it and any attachments from your system. Thank you, Solucient LLC (rev eXclaimer 2x)


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