Date: Tue, 25 May 2004 13:59:24 -0400
Reply-To: Peter Crawford2 <peter.crawford@BLUEYONDER.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Peter Crawford2 <peter.crawford@BLUEYONDER.CO.UK>
Subject: Re: Input comma delimited file
As this is a csv file, I would like to recommend a very useful
feature of sas infile statements DSD
It makes this step a lot simpler, as long as you declare
your variables before using them... See this proposal
DATA TEST;
INFILE FILEIN1 dsd /* implies comma delimiter */;
length EMAIL $46 CUST_NUM 8;
INPUT EMAIL CUST_NUM ;
RUN;
PROC PRINT DATA = TEST (OBS=250);
RUN;
Not only does the DSD option imply that comma delimiter,
it also adds support for
consecutive delimiters - implying a missing column,
quotes that protect delimiters embedded in data
embedded blanks in character data ( delimiters take precedence )
There may be more reasons to applaud DSD, but I would have to start
thinking.....
Peter Crawford
Crawford Software Consultancy Limited
UK
On Tue, 25 May 2004 11:55:19 -0400, Gerhard Hellriegel <ghellrieg@T-
ONLINE.DE> wrote:
>On Tue, 25 May 2004 11:10:14 -0400, Lu Liu <Lu.Liu@TALBOTS.COM> wrote:
>
>>Hi,
>>
>>I have a beginner's question. I used the following codes to input a
comma
>>delimited file with 2 variables, email (min 19, max 46) and customer
number
>>(min 7, max 8). But I am only getting the first 8 columns in the email
>>field. How do I correct it?
>>
>>DATA TEST;
>> INFILE FILEIN1 DLM=',';
>> INPUT EMAIL $ CUST_NUM;
>>PROC PRINT DATA = TEST (OBS=250);
>> RUN;
>>
>>
>>
>>Obs EMAIL CUST_NUM
>>
>> 1 RJBEAN10 1005661
>> 2 CAROLGEL 1050773
>> 3 JLCRIBBS 1063455
>> 4 UTA@SONG 1073812
>> 5 MYRNA@EP 1114518
>>
>>Thank you very much for your help!
>>
>>Lu
>
>you should use:
>
>DATA TEST;
> INFILE FILEIN1 DLM=',' missover;
> INPUT EMAIL : $46. CUST_NUM : 10.;
>PROC PRINT DATA = TEST (OBS=250);
> RUN;
|