Date: Sun, 24 Sep 2000 00:36:42 +0100
Reply-To: Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Organization: Crawford Software Consultancy Limited
Subject: Re: HELP IN READING A FILE
To Prasad's question, Dan has provided an explanation and two solutions
A third might be to replace missover on the infile, with truncover
This option is designed for handling just this situation
Daniel J. Nordlund <dnordlund@aol.com> writes
>prasadp@my-deja.com wrote:
>
>>I am trying to read a file with only 2 variables in it, but somehow I
>>am getting only some values read.
>>
>>I have a file with 2 varibales as shown:
>>
>>TD_ACCOMPLISHMENTS ACCOMP
>>TD_CITIZENSHIP CITIZEN
>>TD_EMERGENCY_CNTCT EMRGCONT
>>TD_EMERGENCY_PHONE EMRGPHON
>>TD_EMPLOYMENT EMPLOYMN
>>
>>
>>Following is my log and output.
>>
>>91 filename tables 'a:\FILE1.sas';
>>92 DATA NAMES;
>>93 INFILE TABLES END=EOF MISSOVER;
>>94 INPUT @1 ORANAME $18. @23 SASNAME $8. ;
>>95 RUN;
>>
>>NOTE: The infile TABLES is:
>> File Name=a:\FILE1.sas,
>> RECFM=V,LRECL=256
>>
>>NOTE: 5 records were read from the infile TABLES.
>> The minimum record length was 28.
>> The maximum record length was 30.
>>NOTE: The data set WORK.NAMES has 5 observations and 2 variables.
>>NOTE: DATA statement used:
>> real time 0.06 seconds
>>
>>
>>96 PROC PRINT DATA = NAMES NOOBS;RUN;
>>
>>NOTE: PROCEDURE PRINT used:
>> real time 0.04 seconds
>>
>>
>>My output comes out as :
>>
>> ORANAME SASNAME
>>
>>TD_ACCOMPLISHMENTS
>>TD_CITIZENSHIP
>>TD_EMERGENCY_CNTCT EMRGCONT
>>TD_EMERGENCY_PHONE EMRGPHON
>>TD_EMPLOYMENT EMPLOYMN
>>
>>
>>I am not getting any value in SASNAME for TD_ACCOMPLISHMENT and
>>TD_CITIZENSHIP.
>>
>>
>>I would appreciate if anybody can help me in reading this file. I tried
>>using RECFM=F to change the file from Variable block to Fixed Block
>>still it did not work.
>>
>>
>>Thanks
>>
>>Prasad
>>
>
>Prasad,
>
>the problem is that you are forcing SAS to read 8 characters for SASNAME, and
>the first two records end before it can read them. Two possible solutions
>among many:
>
>1. Use the colon (:) format modifier on the SASNAME format
>
>filename tables 'a:\FILE1.sas';
>DATA NAMES;
> INFILE TABLES END=EOF MISSOVER;
> INPUT @1 ORANAME $18. @23 SASNAME :$8. ;
>RUN;
>
>2. Use a length statement and remove the formats from INPUT. You can even
>remove the @1 and @23.
>
>filename tables 'a:\FILE1.sas';
>DATA NAMES;
> length oraname $18 sasname $8;
> INFILE TABLES END=EOF MISSOVER;
> INPUT @1 ORANAME @23 SASNAME ;
>RUN;
>
>Hope this helps,
>
>Dan Nordlund
>
--
Peter Crawford
|