Hi SAS Expert Team,
I have a query reading the large VB file in Mainframes. File specs are below.
File length = 11504
File Type = VB (Variable block)
Contains Records with variable length. Example : If record 1 have the length of 765, then the rest of the characters in the observation 1 are null values. At position, 766 there will be CRLF that will specify the end of the observation.
All the obseravations start with the date in the format 'YYYYMMDD' format.
Many instances, thre is a need to filter data on basis of
> DATE in the first 8 characters and
> customer-id placed randomly in the observation
> Invoice Number placed at the fixed position of 65.
How should I write a DATA step to read a Mainframe VB file and create sub-file based on the criteria.
Regards,
Kumar.
Do you run SAS on the mainframe or another platform?
If another platform, do you have direct FTP access to the MF or do you receive the file via another path?
So, how far have you come already?
Did you have problems with the INFILE statement on z/OS?
The first thing I'd try would be the RECFM=VB option in the infile statement. For VB files, z/OS maintains a separate 4-byte RDW (record descriptor word) that holds the current record length in its first two bytes. This eliminates the need for record separators.
Omitting the RECFM= options forces SAS to use any CRLF or similar combination (LF only, eg) as a record separator.
With RECVM=VB, you should not have line skips when a CRLF is encountered in the data.
Try this:
data fileout;
infile filein1 recfm=vb lrecl=11504 truncover;
input
var1 $1.
date_var $8.
rest_string $11493.
;
run;
If that doesn't fix your CRLF problem, you need to have those CRLFs stripped before you read into SAS.
Alternatively you could try to read with recfm=n (this reads the input as a non-formatted stream), read chunks of, say, 100 bytes into a large buffer until you find the line-delimiting '**' in your buffer, and work data out of the buffer. Then start reading again until you encounter the next '**' or EOF.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: