04-06-2017 06:29 AM
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.
04-06-2017 10:42 AM
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
04-07-2017 05:40 AM
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