Hi -
I was searching through answers but unable to find how to convert the following into SAS format.
I have a COBOL format of pic s9(9) usage comp.
I tried converting using IB4 and also RB4. Both results are the same, and it does seem to work but after I reviewed the actual values(from a DB2 table) I see that they do not match.
Does anyone know what is the correct format I should be using?
Thanks in advance - Gregg
0006A0E1 is binary for 434401, so you should read from position 3 with IB4.
If it is a typical DB/2 unload file, the informat would be PD5.
Thanks. Seems to make sense, but I get all 0 values when I read in SAS format and output. This what I originally tried actually. Then tried the IB4 format, which does produce results, but when I match against the DB2 table, they are not alike.
Inspect the file with some kind of hex viewer, or convert the input line (_infile_) to a hex format, to see the raw values and get a feel for the field lengths.
I was able to view the data.
So this is what I have so far:
How it is defined in COBOL load file:
10 ACC-CONVN-REQ-I PIC S9(9) USAGE COMP.
I am reading in a mainframe SAS proc and have tried these:
@001 ACC_CONV_ID PD5. - Get all zeros
@001 ACC_CONV_ID ZD9.0 - As suggested from another response. Also get all zeros.
@001 ACC_CONV_ID IB4. - Get values that do not match the source as below:
10485766 03/14/2005
10485767 07/05/2005
10485767 08/15/2005
10485767 08/15/2005
10485767 09/12/2005
Should look like this:
434401 03/14/2005
477459 07/05/2005
493892 08/15/2005
497050 08/15/2005
512974 09/12/2005
In Hex the first example looks like this:
.µ..µ÷03/14/2005
0A00AEFF6FF6FFFF
0006010311412005
Thanks!
0006A0E1 is binary for 434401, so you should read from position 3 with IB4.
Thank you!! That works!
434401 03/14/2005
477459 07/05/2005
493892 08/15/2005
What OS is your SAS session running on? Is the DB2 data you are reading EBCDIC-encoded or not? If you are reading EBCDIC data on an ASCII OS like Unix or Windows then you will need to use an S370 informat. This SAS Note will help:
https://support.sas.com/kb/56/654.html
Thanks. It is in EBCIDIC. I will keep this link for future reference. But still having issues with the format.
I think the right informat is Zoned Decimal, e.g. ZD9.0, if you are not working on the mainframe, you should use S370FZD9.0,
Thanks. I tried this, but I am getting all zeros.
Thanks. No luck. Comes out as all zeros.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.