BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8

what does this format means, I read the sas documentation and dont get it

S370FPD9.0

 

if the variable apple come in from in input statment like this

 

input apple S370FPD9. (after an infile ".../.../amb.txt" statement)

 

what exactly is its format? 

 

 

3 REPLIES 3
Oligolas
Barite | Level 11

Take a look a the documentation

S370FPD Format

Writes packed decimal data in IBM mainframe format.

Use S370FPD wd in other operating environments to write packed decimal data in the same format as on an IBM mainframe computer.

Value of x
Result
128
0000128C
________________________

- Cheers -

Kurt_Bremser
Super User

The informat has no effect on the display format. It just controls how data is read into the SAS environment from an external source.

 

First of all, follow Maxim 1 and read the documentation: S370FPDw.d Informat 

 

The Packed Decimal format is used on IBM mainframes to store numbers. Each digit is stored in 4 bits, and the last 4-bit nibble is used for the sign. Your informat with a length of 9, without decimals, will therefore read an integer number with at most 17 digits.

Tom
Super User Tom
Super User

Your first problem is that this code is using an INFORMAT and not a FORMAT.  So look for the documentation on the informat, not on the format.

 

Remember:  FORMATs convert values into text.  INFORMATs convert text into values.

 

So that informat specification of S370FPD9.0 says to read 9 bytes from the text file and interpret it as a binary encoded decimal value using on System 370 computers (IBM Mainframes).  The zero means that it will divide the result by 10 to the power 0 (which is just 1) to indicate where the implied decimal point will be placed.  So it is read an integer value.

 

A packed decimal value stores one decimal digit in each nibble. (An 8 bit byte consists of two 4 bit nibbles).  This means that you are reading BINARY data from that text file and converting it into an integer number.  So if you want to check your resulting number against the value in the text file and see what it is doing you will need to print those 9 bytes using the $HEX format instead of normal $ format so you can see what each nibble contains.

 

The only tricky part is the last nibble is used to indicate the sign of the number.

 

Run some test to see what S370FPD format and informat do.

data test;
  do number=-1,0,1,1234,123456789 ;
     string = put(number,s370fpd9.0);
     format string $hex18.;
     number2 = input(string,s370fpd9.0);
     output;
  end;
run;

proc print;
run;

Tom_0-1684159065894.png

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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