BookmarkSubscribeRSS Feed
JWince
Calcite | Level 5

Hello,

I have a large, fixed-width flat file that I need to download from a mainframe. Is it possible to download and import the data at the same time. I'm using proc download to retrieve the file. The file downloads quickly, but when I try to import, it takes a long time and eventually runs out of memory (using the SAS import function after download).

 

Thanks in advance!

2 REPLIES 2
ballardw
Super User

The snarky answer is "it depends". If your system with SAS running can read the disk of the mainframe then yes, you could write code to read the file directly though can run into some interesting technical issues (ancient File block size is one).

 

If by "import" you mean use Proc Import. NO. Proc import really will not guess at all correctly where variables start and end unless your fixed column data is unusual. You need a description of the text file with which values are in which columns and write a data step.

The description should include, as a minimum, which column each value starts in and either a length or the ending column, plus whether the value is character, numeric, date, time or a datetime value. Dates, times and datetime values should include the appearance or layout as a date that looks like : 010203 (if using 2-digit years) is almost impossible to guess which is month, day or year in the value. Warning: look out for Julian dates as well.

 

If you don't have documentation of the file structure, find it. Otherwise you are very likely to be very frustrated in may ways. The nice thing is that with good documentation it is relatively easy, though tedious with many variables, to write a data step to read them. The basic input syntax for SAS is like the following where the 1-5 is read from column 1 to column 5 for the value of var1. If the value is character place a $ before the starting column

data nameofset;
   infile <path and name of file>;
   input 
       var1 1-5
       var2 6-26
   ;
run;

Provide INFORMATS for special values like date, time or datetime. Currency values should have a COMMA informat assigned. You can either specify the informat on the Input statement or separate Informat or Attribute statements.

You should have examples in the online help for INPUT statement.

 

Tom
Super User Tom
Super User

Do you need to text file or just the dataset it converts into?

If the later then convert the file into a dataset and download that.

Note you cannot use PROC IMPORT to GUESS how to read a fixed position text file.  You have to actually read it yourself.

So the structure of the code will look like this:

rsubmit;
data for_download;
  infile TEXT ;
  input .... ;
run;
proc download data=for_download out=want ;
run;
endrsubmit;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 244 views
  • 0 likes
  • 3 in conversation