Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

converting a zonal decimal to numeric in SAS

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
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    Post subject: converting a zonal decimal to numeric in SAS
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Sat May 28, 2011 12:46 am    Post subject: Reply to: converting a zonal decimal to numeric in SAS
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
http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dz9zr002/CCONTENTS
here
http://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
https://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: 7905
Location: Bellevue, IA

PostPosted: Sat May 28, 2011 1:05 am    Post subject:
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

Active Member


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

PostPosted: Sat May 28, 2011 6:17 am    Post subject:
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

Site Director


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

PostPosted: Sat May 28, 2011 8:08 am    Post subject:
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    Post subject: Re:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Sat May 28, 2011 3:49 pm    Post subject:
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Sat May 28, 2011 3:57 pm    Post subject:
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    Post subject:
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Sat May 28, 2011 4:22 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm
No new posts Converting multiple VB files to FB fi... Viswanath Reddy JCL & VSAM 6 Mon Aug 08, 2016 11:49 pm
No new posts Converting NULL column into NOT NULL ... Raghu navaikulam DB2 5 Sat Aug 06, 2016 3:45 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us