Write and run SAS programs in your web browser

Fixed Width Text Files

Reply
SAS Employee
Posts: 3

Fixed Width Text Files

With SAS Studio, Is there an easy way to read in a fixed width format .txt file?

Thanks

Grand Advisor
Posts: 9,713

Re: Fixed Width Text Files

Do you have a document with column descriptions such as variable name start -end column for each field and the data format (currency, date, time, datetime, numeric, numeric with implied decimals, text)?

SAS Employee
Posts: 3

Re: Fixed Width Text Files

Yes, I have all that - I am trying to avoid writing code. I am look for a Wizard like we have in EG
Grand Advisor
Posts: 16,315

Re: Fixed Width Text Files

You have to write code for fixed width files because SAS can't tell where a variable will start and end. If your documentation is structured well you can usually use Excel to help write the code.

Or you can try and write some code that reads the specifications and develops the import code.
SAS Employee
Posts: 3

Re: Fixed Width Text Files

Thanks - SAS STUDIO does not have a point and click for fixed width files.

SAS Employee
Posts: 145

Re: Fixed Width Text Files

Just so you know, there's a lot we want to do to the Import Tool.  Right now it can handle basic importing of common file types and generates PROC IMPORT code.  Seemed like a good place to start.  But ulitmately, I'd love to have a "DATA step generator" that would allow you to view a sample of your raw file and help you build the INPUT statement for it.  We don't have that yet.  I'd love to hear any ideas or pointers to any good examples of something similar out there.

Valued Guide
Posts: 2,152

Re: Fixed Width Text Files

Hi Amy
I helped "industrialize" an data step import routine. However, that was for a collection of csv files for which the definition were provided in very similar structure to OUT= of the CONTENTS Procedure.
A form for defining the old fashioned fixed layout should (just about) be simpler..... but seems hard to visualise the way to support the maximum number of columns a table can have. Is there a way to insert "another page" of definitions.
Post a Question
Discussion Stats
  • 6 replies
  • 340 views
  • 0 likes
  • 5 in conversation