Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
using SORT to sort decimals from highest to lowest.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
relur197

New User


Joined: 31 Jul 2008
Posts: 18
Location: Massachusetts

PostPosted: Fri Aug 08, 2008 8:46 pm    Post subject: using SORT to sort decimals from highest to lowest.
Reply with quote

In my current issue I can't find the right syncsort commands to sort this list from highest to lowest. I am currently sorting on the 81st column and sometimes there decimals can get as big as 5 characters long. My current output from the below jcl is this:

Code:

95.26
9.67 
9.66 
9.65 
9.52 
9.49 
9.46 
9.41 
9.4   
9.37 
9.24 
9.15 
9.06 
875.42
86.64
86.64
83.94
82.38
8.94 
8.9   



JCL:
Code:

//STEP2    EXEC DISKSORT                             
//SORTMSG  DD SYSOUT=R                               
//SORTIN   DD DSN=T836.PX8006.RRH.MEP.NMCFF,DISP=SHR
//SORTOUT  DD DSN=T836.PX8006.RRH.MEP.NMCFFF,DISP=SHR
//SYSIN    DD *                                     
 SORT FIELDS=(81,5,PD,D)                             
/*         



DATA:
Code:

53.07
13.97
1.66
0.21
0.05
0.03
0.09
0.03
1.05
0.32
0.73
0.1 
0.09
0.26
11.14
0.62
0.03
1.38
6.15
0.03
0.15
0.02
0.45
21.72
0.03


Please note that this list of decimals is quite large and I only took a subset.
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Aug 08, 2008 8:59 pm    Post subject:
Reply with quote

SORT FIELDS=(81,5,PD,D)

What you are showing above is not PackedDecimal!
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2285
Location: @my desk

PostPosted: Fri Aug 08, 2008 9:02 pm    Post subject:
Reply with quote

Hello relur197,

The below SYNCSORT does what you asked for. I assumed data starting at postion 1 and the maximum data length as 6(including decimal point). You might want to change it as per your attributes.

Input
Code:
95.26
9.67 
9.66 
9.65 
9.52 
9.49 
9.46 
9.41 
9.4   
9.37 
9.24 
9.15 
9.06 
875.42
86.64
86.64
83.94
82.38
8.94 
8.9   


SORT card
Code:
//SYSIN    DD *                                 
 INREC FIELDS=(1,6,UFF,TO=PD,LENGTH=4)           
 SORT FIELDS=(1,4,PD,D)                         
 OUTREC FIELDS=(1,4,PD,EDIT=(SIIT.TT),SIGNS=(,-))


SORTOUT
Code:
 875.42
  95.26
  86.64
  86.64
  83.94
  82.38
   9.67
   9.66
   9.65
   9.52
   9.49
   9.46
   9.41
   9.37
   9.24
   9.15
   9.06
   8.94
   0.94
   0.89


Thanks,
Arun
Back to top
View user's profile Send private message
relur197

New User


Joined: 31 Jul 2008
Posts: 18
Location: Massachusetts

PostPosted: Fri Aug 08, 2008 9:13 pm    Post subject:
Reply with quote

Hi Arun,

I used your jcl, and replaced your parms with mine.

Code:

//SYSIN    DD *                                   
 INREC FIELDS=(81,6,UFF,TO=PD,LENGTH=4)           
 SORT FIELDS=(81,4,PD,D)                         
 OUTREC FIELDS=(81,4,PD,EDIT=(SIIT.TT),SIGNS=(,-))
/*                                               


I was getting a U016, and this was the error I retrieved.

Code:

WER257I  INREC RECORD LENGTH =     4         
WER230A  OUTREC   FIELD OUTSIDE RANGE       
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2285
Location: @my desk

PostPosted: Fri Aug 08, 2008 9:21 pm    Post subject:
Reply with quote

Hello relur197,

You should be using a card like this.

Code:
 INREC FIELDS=(81,6,SFF,TO=PD,LENGTH=4)           
 SORT FIELDS=(1,4,PD,D)                         
 OUTREC FIELDS=(1,4,PD,EDIT=(SIIT.TT),SIGNS=(,-))


Thanks,
Arun
Back to top
View user's profile Send private message
relur197

New User


Joined: 31 Jul 2008
Posts: 18
Location: Massachusetts

PostPosted: Fri Aug 08, 2008 9:25 pm    Post subject:
Reply with quote

Thanks Arun for all your help so far but I should have been more on point with my request for help.

This is the data

Code:

ESMFXN                           53.07
ESMFYN                        13.97
OPSARCHE                      1.66
DAIMRGE                       0.21
DAISORT                       0.05
ESSX0FDW                      0.03
ESSX0STR                      0.09
ESSX0ST1                      0.03
EZDASUS                       1.05
GABX501                       0.32
GABX594                       0.73
GABX597                       0.1 
GAHX006                       0.09
GAHX011                       0.26
GAKX400                       11.14
GAOX1SEC                      0.62
JABX0BKP                      0.03
JABX0EG                       1.38
JABX0FDA                      6.15


I need the decimals sorted from highest to lowest but along with taking everything else that is on the line with it. including these member names.
There is also more infomation on the line. The infomation starts at column 1, and the decimals dont start until column 81 and they go for a max of 6 columns.

Sorry once again, and thanks.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2285
Location: @my desk

PostPosted: Fri Aug 08, 2008 9:34 pm    Post subject:
Reply with quote

Quote:
Sorry once again, and thanks


No probs. Can you post here the following.

1) Input LRECL
2) Length of first field
3) Fields you want to have SORTed(other than that starting at pos 81)
4) Fields you want in output

Thanks,
Arun
Back to top
View user's profile Send private message
relur197

New User


Joined: 31 Jul 2008
Posts: 18
Location: Massachusetts

PostPosted: Fri Aug 08, 2008 9:37 pm    Post subject:
Reply with quote

1.) 125 is the input lrecl.
2.) the length of the first field is variable because it is a dsn. But it will never exceed 40 characters. the second field starts at pos 51. and the second field will never exceed 8 characters.
3.) I just need the field starting as pos 81
4.) I want the all fields in output.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2285
Location: @my desk

PostPosted: Fri Aug 08, 2008 9:49 pm    Post subject:
Reply with quote

Hello relur197,

Code:
4.) I want the all fields in output.


Got a bit confused. icon_rolleyes.gif Can you post the entire layout.
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 Aug 09, 2008 1:15 am    Post subject:
Reply with quote

Hello,

I believe the requirement is to simply sort the file on positons 81-86 but to take into account the decimal field when sorting.

When the process completes, the output file will have the exact same content as the input, just in order by the decimal field descending.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sat Aug 09, 2008 2:21 am    Post subject:
Reply with quote

I don't usually respond to Syncsort questions, but as the inventor of the UFF format (for DFSORT), I can't stand to see it misused so badly. Nobody posting here seems to understand how it really works.

If the input values were all of the form d...d.dd, for example:

123.45
1.23
1.50

then you wouldn't need to change the values with INREC and OUTREC - you could just use UFF in the SORT statement directly. UFF would interpret these values as:

12345
00123
00150

and sort them correctly.

But among the values are some with only one decimal place, like:

1.5

UFF would interpret that value as 00015, not 00150 so it wouldn't be placed in the correct order.

To sort values with different numbers of decimal places correctly, you must "normalize" them first. For example, 1.5 must be changed to 1.50 to match the values with 2 decimal places like 1.23.

Here's a DFSORT job that will sort these mixed 1 and 2 decimal place values correctly. It uses PARSE to separate the digits before the decimal point from the 1 or 2 digits after the decimal point and normalizes 1 digit after the decimal point to 2 digits after the decimal point. After that's done, it uses UFF to sort the values.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/125)
//SORTOUT DD DSN=...  output file (FB/125)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,
    PARSE=(%01=(ABSPOS=81,ENDBEFR=C'.',FIXLEN=6),
           %02=(FIXLEN=2)),
    OVERLAY=(126:%01,132:%02)),
   IFTHEN=(WHEN=(133,1,CH,EQ,C' '),OVERLAY=(133:C'0'))
  SORT FIELDS=(126,8,UFF,D)
  OUTREC BUILD=(1,125)
/*


Code:

...      875.42
...      95.26
...      86.64
...      86.64
...      83.94
...      82.38
...      9.67
...      9.66
...      9.65
...      9.52
...      9.49
...      9.46
...      9.41
...      9.4        <--- note this is .4, not .40
...      9.37
...      9.24
...      9.15
...      9.06
...      8.94
...      8.9        <--- note this is .9, not .90
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2285
Location: @my desk

PostPosted: Sat Aug 09, 2008 8:51 am    Post subject:
Reply with quote

Frank,

My apologies. I overlooked the results. Thanks for making it clear.

Thanks,
Arun
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts OC4 in SORT Mohan Kothakota DFSORT/ICETOOL 2 Tue Sep 12, 2017 6:30 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm
No new posts Changing sort Card Dynamically vickey_dw DFSORT/ICETOOL 5 Sat Aug 19, 2017 2:33 pm
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us