BookmarkSubscribeRSS Feed
TingSern
Obsidian | Level 7

Hi,

 

I am running SAS 9.4 on z/OS 2.1.

 

SAS INFILE statement has constructs to read RAW data in fixed or variable length records.

If I want to read a fixed length record, I just code -

INFILE ddname ;

If I want to read a variable length record, I have to code -

INFILE ddname LRECL=maxlength MISSOVER PAD ;

 

I am wondering whether it would be possible to determine at runtime -

 

a) What attributes a dataset has (the ddname) - whether it is fixed, or variable (RECFM=FB or VB), and the LRECL of the file

b) And using the attributes to determine which INFILE statement to be executed?

 

I know from assembly programming (I have 40+ years of z/OS systems programming knowledge) - it is possible to get these information from RDJFCB macro or after you open the file, the fields are in the DCB of that file.  I wonder whether it is possible to get these information back to a SAS program.

 

If this is a traditional programming language (PL/1, COBOL, Assembler, etc) - the programming code to handle a Fixed or Variable records is the same. The OS takes care of that (we merely have to tell the DCB what the RECFM is - FB or VB). Unfortunately - I can't say the same thing for SAS.

 

Thank you.

2 REPLIES 2
ballardw
Super User

Infile has very little to do with how the data is treated. The INPUT statement is used to specify whether you are reading fixed columns, list, formatted or named input, or a mixture of the 4.

Fixed data usually comes with a description of which columns are used for which values/variables.

 

Or perhaps we are using "fixed" in two different manners. 

 

And depending on your actual datafile INFILE ddname ; may not read a fixed length record if the length exceeds the the default LRECL value for you OS.

 

The PAD option is only typically needed if you have a read process that attempts to force reading past an end of record marker in the input data file. And the MISSOVER causes the DATA step to assign missing values to any variables that do not have values when the end of a data record is encountered. The DATA step continues processing. So in many cases either PAD or MISSOVER accomplish the same thing.

 

It may help to provide a more concrete example as the record type at the OS level, fixed or varying has little to do with the content per record. For instance all of the three followng lines could be considered as "fixed length" of 27 columns (hopefully from different files).

The first uses named input and the second could be either fixed column or formatted input and the third uses list input.

a=27 b=345 c=9999 d=123.456
123456789234567889900089777
John Smith 123.45 44.77  AB
TingSern
Obsidian | Level 7

Hi,

 

After reading your post - I realised that the "LRECL=132 MISSOVER PAD" will work - for both fixed and variable records.  I proceeded to test that assumption on my z/OS system - and yes - it works.  Thank you

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1700 views
  • 0 likes
  • 2 in conversation