On Sun, 16 Nov 2008 20:33:21 -0800, Daniel Nordlund
>> -----Original Message-----
>> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On
>> Behalf Of John F. Regus
>> Sent: Sunday, November 16, 2008 7:19 PM
>> To: SAS-L@LISTSERV.UGA.EDU
>> Subject: old SAS guy with new SAS question
>> You three were of the most help to an old man in simplifying
>> how to get output from my PC file into a SAS dataset.
>> However, when I did use the INPUT statement I coded INPUT $.
>> thinking this would put everything into its natural place in
>> the output SAS table. Wrong. It only got the first variable
>> of 5 characters.
>> I went through my "Little SAS Book" trying to find the answer
>> to this but the "Little SAS Book" has an appropriate
>> title...it is little and does not cover a lot of things.
>> SAS help and documentation takes you over the hills and
>> through the woods without getting to the point or even a
>> concise answer.
>> Here is my problem.
>> I am reading a .csv PC flat file (I conquered the problem of
>> reading the PC file into a SAS dataset by adding the INPUT
>> statement...only not all the data goes through because I need
>> to use columnar input instead of list input).
>> The layout of the .csv PC flat file is somewhat like this,
>> with the variable lengths inside each table entry looks
>> something like this:
>> VAR1 VAR2 VAR3 VAR4 VAR5 etc.,etc.
>> Row1 5$ 1$ 1$ 8$ 6$
>> Row2 5$ 2$ 1$ 18$ 6$
>> Row3 5$ 4$ 1$ 10$ 6$
>> Row4 5$ 4$ 1$ 6$ 6$
>> Row5 5$ 3$ 1$ 9$ 6$
>> Row6 5$ 1$ 1$ 12$ 6$
>> ...and so on.
>> Obviously, it is impossible to count each row of the .csv
>> file and find the variables with varying lengths and then
>> code an INPUT statement at exactly the number of rows the
>> variables with the varying lengths were found in the PC file.
>> In my PC file, their are 72000+ lines of data (one month's
>> worth of Demantech's NTSMF performance data). So how do I
>> code a DATA step that figures out there are variable length
>> variables scattered throughout the PC flat file so that I can
>> come back and code another DATA step with names for the
>> COLUMNS where all of the data resides?
>> Any and all help would be appreciated, and I will try
>> everything you say.
> length row var1-var5 $20;
> infile "c:\temp\variable_length_data.txt" ;
> input ROW VAR1 VAR2 VAR3 VAR4 VAR5;
I am not quite following, but have a suggestion anyway :)
infile "c:\temp\variable_length_data.txt" DSD Delimiter = "2c"x LRECL =
The changes are DSD (delimiter-separated data?), specification of the
delimiter (comma), and increasing the default logical record length. I
assume that records that have incomplete data at their terminus still have
commas. Otherwise, you may need to look at other options (truncover,