| Date: | Thu, 28 Jan 1999 09:32:42 +0000 |
| Reply-To: | Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK> |
| Sender: | "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU> |
| From: | Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK> |
| Subject: | Re: Delimited text file fields longer than 8 characters |
| In-Reply-To: | <917474935.1026863.4@vm121.akh-wien.ac.at> |
In article <917474935.1026863.4@vm121.akh-wien.ac.at>, Boylan, Dave
<dboylan@UTILICORP.COM> writes
>I'm having trouble reading a delimited text file with varying length fields
>longer than 8 characters. It seems that SAS truncates the character field
>after the 8th character.
<<< that is the *expected behaviour* with your input statement code
.... but there _are_ many ways to take control ....
Although the code to deal with the the whole issue inside the input
statement makes it more complex
~~ simplifying helps, just by letting the input statement know a little
about the variables it is dealing with beforehand, with an informat
or length statement
>For example, a text file record like:
>
> 100,9999,bill,hello world,755
>
>read with the following SAS program:
>
> Data Junk;
> infile raw dlm=',';
*<<<add this length statement --------------<<<<<
length comment $40 ;
> **** input num1 num2 name $ comment $ num3;
*<<<then you can remove those $ signs --------<<<<<
> input num1 num2 name comment num3;
> run;
>
>Gives the following results:
>
>num1 num2 name comment num3;
>100 9999 bill hello w orld755
>
>I'm sure that I am missing something simple here.
>
>Thanks
>--------------------------------------
>David Boylan
>Corporate Forecasting
>UtiliCorp United, Inc.
>816.467.3062
>--------------------------------------
removing the $ from input statements, and preceding with a length
statement, produces this data in fsview
+FSVIEW: WORK.JUNK (B)----------------------------------------+
| OBS NAME COMMENT NUM1 NUM2 NUM3 |
| |
| 1 bill hello world 100 9999 755 |
| |
| |
+--------------------------------------------------------------+
The log looks like
1 Data Junk;
2 infile raw dlm=',';
3 length comment $40 ;
4 * input num1 num2 name $ comment $ num3;
5 input num1 num2 name comment num3;
6 run;
NOTE: The infile RAW is:
FILENAME=C:\business\data\sas\raw.dat,
RECFM=V,LRECL=256
NOTE: 1 record was read from the infile RAW.
The minimum record length was 29.
The maximum record length was 29.
NOTE: The data set WORK.JUNK has 1 observations and 5 variables.
NOTE: The DATA statement used 0.22 seconds.
--
Peter Crawford
|