BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8

Need help with informats for the follwoing.

  I'm reading a Mainframe file to SAS. The fields on Mainframe file have the following formats:

Date:   PICTURE S9(7)

             startling at column 1 and ending at column 7. The length is 7

Time:  Picture 9(6)

            startling at column 8 and ending at column 16. The length is 6

GRP-CD:  picture         X(4)             

                 startling at column 66   and ending at column   69.The length is       4

5 REPLIES 5
OS2Rules
Obsidian | Level 7
SASPhile
Quartz | Level 8

Thanks 0s2.but it is confusing.

OS2Rules
Obsidian | Level 7

My recommendation has always been to find the oldest person in the IS department and ask them about this stuff.  We still use COBOL code written in 1992 for god's sake.  Warning - when you do ask them prepare to have your ears talked off about the "good old days" when men were men and computers were as big as your living room.

Sanyam
Calcite | Level 5

Hi SASPhile,

The informats to be used for reading the specified mainframe fields should be as :

INPUT

  @1  Date            DATE7.                  

  @8  Time               PD6.

  @66 GRP-CD   $CHAR4.

  ;

Explanantion :

It would be more clear if you provide the some examples of data for the date and time field.

1. Date:   PICTURE S9(7)

             startling at column 1 and ending at column 7. The length is 7

-> COBOL format : PIC S9(7)

Generally, we use ZD7. as an informat to read this type of data as S9(7) represents signed data with 7 numeric digits. But in your case, we are reading a date so a date with 7 length, the informat to be used should be DATE7.

2. Time:  Picture 9(6)

            startling at column 8 and ending at column 16. The length is 6

-> COBOL format : PIC 9(6)

Generally, to read this type of data if it is standard numeric data the informat to be used should be 6.But in you case the starting column is 8 and ending column is 16 so total number of columns to be read equals to 9. So, this type of data should be Packed Decimal Data.

To read this type data we have informat

PDw.d

  • w is the total number of bytes the field takes up on the record(not the total number of digits). d represents the number of digits to the right of the decimal point. The d value is 0-10.
  • To calculate w, the length of a packed field, use the following formula

        (Total Digits/2) + 1/2

        Round his number if it ends in 1/2

3. GRP-CD:  picture         X(4)            

                 startling at column 66   and ending at column   69.The length is 4.

-> COBOL format : PIC X(4)

This format means we are reading 4 character digits. So, this type of data can be read using the informat $CHAR4. as the variable GRP-CD may have leading zeroes.

It would be great if you specify some examples that would show the clear view of what exactly are you going to read.

Thanks!

jakarman
Barite | Level 11

SAS(R) 9.4 Formats and Informats: Reference (S370FPDw.d Informat )

The last part of text is telling the cobol equivalents.

The easiest approach is assuming the SAS code is also run on a mainframe.

You could read SAS mainframe data on other machines. 

The transfer must be binary and record information (input statement) given,

---->-- ja karman --<-----

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 1644 views
  • 0 likes
  • 4 in conversation