BookmarkSubscribeRSS Feed
JohnDawson
Calcite | Level 5

I have defined an input field on my input file in SAS as @243  TIER4MAX   PD9.3 This field was created by a COBOL modules that had a PIC clause as PIC S9(13)V999 COMP-3. The SAS module simply read in the data and put it into a SAS dataset with no manipulation. The input value looked like this:

 rrrrrrrærrrrrrrræ rrræ rrrrrrrærrrrrrrrærrrræ
0999999999999999990999909999999999999999999999
99999999C99999999C9999C99999999C99999999C9999C

 

We use SAS V9.4

 

When I run the SAS code my output looks like this:

 rrrrrrrðrrrrrrrræ rrræ rrrrrrrðrrrrrrrrærrrræ
0999999989999999990999909999999899999999999999
99999999C99999999C9999C99999999C99999999C9999C

 

Notice that first and fourth field had the last byte changed from Hex '9C' to Hex '8C' . Fields 1, 2, 4 & 5 are defined as PD9.3 while fields 3 & 6 are defined as PD5.3. Fields that are defined with PD9.3 and contained all 9's stayed the same, but the fields that contained all 9's except for the left most bit had the bit before the sign changed to Hex '8C'. Field 3 contained Hex ;099999999C and it stayed the same on the output.

 

So does anyone know why Hex '9C' was replaced with Hex '8C' on the 2 larger fileds, and how can this conversion be prevented.

8 REPLIES 8
mkeintz
PROC Star

How are you producing the hexadecimal output content?

 

If you just issue something a statement like  "put tiermax=best32.6", do you see the intended value?

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
JohnDawson
Calcite | Level 5

When I changed the format on the put statement from @243  TIER4MAX   PD9.3  to  @243  TIER4MAX  best32.6   it changed the outout to spaces, so that didn't work

art297
Opal | Level 21

Have you tried with a different informat? Different ones have to be used if you're inputing a file from a different operating system. See: http://support.sas.com/kb/56/654.html

 

Art, CEO, AnalystFinder.com

 

JohnDawson
Calcite | Level 5

OK, so it looks like I'm out of luck due to a restriction in SAS. Is that correct?

Kurt_Bremser
Super User

When all possible digits are used, you will have an inaccuracy in the last digit. With 3 digits after the decimal point, this happens in the 1/1000 range. Which values do you have that need total accuracy down there?

JohnDawson
Calcite | Level 5

These fields are defined in COBOL as PIC S9(13)V999 and the maximum number I could have in this field would be 9999999999999.999 and in hex it looks like this:

099999999
99999999C

and it gets converted to this:

099999998
99999999C

 

I do manipulate other fields to get my desired results, and then I use this file and compare it to my input file to get a file of differences and these fields that are getting the left most byte converted to Hex '8C' from hex '9C' are throwing a monkey wrench into that process because they shouldn't be different.

So it's not really the accuacy issue, it'd a matter of the contents of the input files has been altered in the outout file that's causing the grief. One good thing is that I can edit the output file after I run my SAS job to change all occuances of Hex '8C' to Hex '9C' and I should be fine to run the compare. I just wanted to know why and could I do something to avoid getting this result.

Kurt_Bremser
Super User

The accuracy problem will only appear with sufficiently large numbers. Run a proc means on real data to get the maximum number that actually appears in the data.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 8 replies
  • 938 views
  • 1 like
  • 4 in conversation