IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

converting a zonal decimal to numeric in SAS


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mambopras

New User


Joined: 11 Nov 2008
Posts: 52
Location: Hyderabad

PostPosted: Sat May 28, 2011 12:25 am
Reply with quote

Hi,
I have a requirement in SAS to read a variable which is a zonal decimal of ZD14.2 and put it in the output as a numeric which can be a max of 9 digits (including decimal if any)
Example - if the value in the input file is
00000002130}00000

I need i is 213.00 or just 213 (with a leading sign if negative).

I have been trying SAS formats but was not successful. Can anyone please help me with this ?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat May 28, 2011 12:46 am
Reply with quote

before posting it would be wise to review Your understanding of numeric data representation and the relative terminology
as described in
z/Architecture Principles of Operation
publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dz9zr002/CCONTENTS
here
publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dz9zr002/8.1?DT=20030424140649

after reading You will understand why the example You posted is not a valid number
Quote:
00000002130}00000

the sign will alway be <zone> part of the less significant digit
so the 5 zeroes to the right of the } are just garbage

and here is link to a downloadable format
www-304.ibm.com/support/docview.wss?uid=isg2b9de5f05a9d57819852571c500428f9a
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Sat May 28, 2011 1:05 am
Reply with quote

Okay, you tell us you have a ZD14.2 SAS value, give us 17 digits, and the value is stored in just the first 12 digits -- obvious due to the sign overlay in the 12th position. I think your first, and most obvious problem, is that YOU HAVE NO IDEA WHAT YOU ARE DOING!

Assuming you really meant 12.2 and not 14.2, why not
Code:
INPUT ... NUMVAR 12.2 ... ;
.
.
.
PUT ... NUMVAR 9.2 ;
to output a 9-digit number with 2 decimal places maximum. If the value is greater than 999,999,999 then you'll get a BEST9. format out of SAS, but that is what you expected, right?
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Sat May 28, 2011 6:17 am
Reply with quote

Your subject also makes no sense.

Zoned decimal, packed decimal, pure binary (aka binary), and a few others are all numeric, just coded differently.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat May 28, 2011 8:08 am
Reply with quote

Hello,

Why do you believe that 00000002130}00000 is a zonal decimal of ZD14.2 icon_confused.gif

This part of the value 00000002130} meets the rules for a signed, zoned decimal with a value of 213.00.

Suggest you review what you actually "have" and what you want to do with this. Hint: how is the output value to be used?
Back to top
View user's profile Send private message
mambopras

New User


Joined: 11 Nov 2008
Posts: 52
Location: Hyderabad

PostPosted: Sat May 28, 2011 3:16 pm
Reply with quote

Well, apologies for my earlier 'not properly' framed question and confusion over terminology.

Requirement :I have an existing SAS program in production that reads an amount field having values like 0000000002130{ from an input file into a variable of ZD14.2. This variable wasn't moved to the out put field earlier. Now, I need to move it into the output such that it gets displayed as 213.00 (Truncating the leading zeros). I tried using NO DOLLAR9.2 etc...but could not get the amount displayed as required.

So what should be the declaration of the variable in the PUT statement was the question I intended to ask - But I couldn't convey that earlier.

The output is used as a report. However, we couldn't use PROC PRINT (which could have taken care of this issue) to generate report as our requirements made us code everything manually due to the extra customization the client wanted.

I hope this explanation is better than the earlier. Can you help me out with this ?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat May 28, 2011 3:49 pm
Reply with quote

Try looking up COMMA or D in the manual, see if either give you what you want.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Sat May 28, 2011 3:57 pm
Reply with quote

put @x value 14.2;
Back to top
View user's profile Send private message
mambopras

New User


Joined: 11 Nov 2008
Posts: 52
Location: Hyderabad

PostPosted: Sat May 28, 2011 4:13 pm
Reply with quote

Peter I tried that way but the leading zeros are not being truncated.
Bill : I tried a NO DOLLAR14.2. It seems to work ok. I would have to do more testing.

Thanks a lot to all of you for your responses and help.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Sat May 28, 2011 4:22 pm
Reply with quote

And this one ? :

char=put(value,14.2);
Back to top
View user's profile Send private message
mambopras

New User


Joined: 11 Nov 2008
Posts: 52
Location: Hyderabad

PostPosted: Sun May 29, 2011 1:08 pm
Reply with quote

Peter, I need to try this!!!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts Convert HEX to Numeric DB2 3
No new posts Converting fixed length file to excel... IBM Tools 7
Search our Forums:

Back to Top