BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gbobay
Calcite | Level 5

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

1 ACCEPTED SOLUTION
11 REPLIES 11
gbobay
Calcite | Level 5

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.

 

 

Kurt_Bremser
Super User

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.

gbobay
Calcite | Level 5

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!

 

 

 

 

gbobay
Calcite | Level 5

Thank you!! That works!

 

434401 03/14/2005
477459 07/05/2005
493892 08/15/2005

SASKiwi
PROC Star

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

 

 

gbobay
Calcite | Level 5

Thanks. It is in EBCIDIC. I will keep this link for future reference. But still having issues with the format.

s_lassen
Meteorite | Level 14

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,

see the SAS documentation. 

gbobay
Calcite | Level 5

Thanks. I tried this, but I am getting all zeros.

gbobay
Calcite | Level 5

Thanks. No luck. Comes out as all zeros.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 3691 views
  • 3 likes
  • 4 in conversation