View previous topic :: :: View next topic

Author 
Message 
birdy K
New User
Joined: 05 Mar 2008 Posts: 72 Location: chennai




Can we do the divide operation in sort? For ex, I have to divide the numeric column by 4 for particular record. How to perform this? 

Back to top 




Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA




Quote: 
You can do arithmetic with numeric fields and decimal constants (+n and −n) using the operators MIN (minimum), MAX (maximum), DIV (division), MUL (multiplication), MOD (modulus), ADD (addition) and SUB (subtraction). The order of evaluation precedence for the operators is as follows, but can be changed by using parentheses: 1. MIN and MAX 2. MUL, DIV and MOD 3. ADD and SUB 
This is from DFSORT getting started...
Read DFSORT Getting started from these docs first
If you are seeking for some specific help, show us some records from input file and desired output for the same. 

Back to top 


Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 7130 Location: San Jose, CA




Quote: 
Can we do the divide operation in sort? For ex, I have to divide the numeric column by 4 for particular record. 
You should have given more details. However, as an example, if you want to divide the ZD value in positions 1115 by 4, you could use DFSORT control statements like this:
Code: 
OPTION COPY
INREC OVERLAY=(11,5,ZD,DIV,+4,TO=ZD,LENGTH=5)

This will give you a 5byte ZD integer result. For example if you divided 00021/4 the result would be 00005.
If you need more specific help, you need to give more details of what you want to do exactly. 

Back to top 



