SORT records on date.

SyncSort's Sort Product, SyncTool for z/OS, SYNCINIT and SYNCLIST.
Previous topicNext topic

Topic Author
SarvanaL
New Member
Posts: 3
Joined: Wed Sep 09, 2015 5:53 pm

SORT records on date.

Post by SarvanaL » Wed Sep 09, 2015 9:40 pm

Hi,

I need to sort the records in a dataset based on date in ascending order. If there are three dates namely 31.1.1998, 2.12.1997,3.6.2014 then output should have 2.12.1997,31.1.1998,3.6.2014

I have used the sort card:

Code: Select all

SORT FIELDS =(60,10,UFF,A) 


But the records are not getting sorted properly. Can you guys please suggest how to solve it.



User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1379
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
Zodiac: Virgo

Re: SORT records on date.

Post by Robert Sample » Wed Sep 09, 2015 10:49 pm

What format are the dates in? You cannot put together a SORT statement without knowing that. Whatever the format, you'll want to sort by year, month, day to get the data in ascending date sequence.




William Collins
Global Moderator
Global Moderator
Posts: 499
Joined: Sun Aug 25, 2013 7:24 pm

Re: SORT records on date.

Post by William Collins » Thu Sep 10, 2015 12:10 am

You'll need to PARSE the fields in INREC, then make a temporary extension to the record. Heed Robert's point about sorting in a logical order (year, month, day).

In OUTREC, use BUILD to return the record to its original size.




Topic Author
SarvanaL
New Member
Posts: 3
Joined: Wed Sep 09, 2015 5:53 pm

Re: SORT records on date.

Post by SarvanaL » Thu Sep 10, 2015 11:47 am

Robert Sample wrote:What format are the dates in? You cannot put together a SORT statement without knowing that. Whatever the format, you'll want to sort by year, month, day to get the data in ascending date sequence.
Dates are in DD.MM.YYYY format.




Topic Author
SarvanaL
New Member
Posts: 3
Joined: Wed Sep 09, 2015 5:53 pm

Re: SORT records on date.

Post by SarvanaL » Thu Sep 10, 2015 11:48 am

William Collins wrote:You'll need to PARSE the fields in INREC, then make a temporary extension to the record. Heed Robert's point about sorting in a logical order (year, month, day).

In OUTREC, use BUILD to return the record to its original size.
Thanks but what are you saying when you say "a temporary extension to the record"?




nicc
Global Moderator
Global Moderator
Posts: 597
Joined: Wed Apr 23, 2014 8:45 pm

Re: SORT records on date.

Post by nicc » Thu Sep 10, 2015 3:40 pm

Internally to sort records can be made longer so if you have an 80 byte record and you want to add your reformatted date (CCYYMMDD) you would ask sort to put it in columns 81-88 (for VB records you extend by inserting the extension after the RDW and before the first byte of 'real' data. You the sort on that added data and remove it when writing the output.


Regards
Nic


enrico-sorichetti
Global Moderator
Global Moderator
Posts: 891
Joined: Wed Sep 11, 2013 3:57 pm

Re: SORT records on date.

Post by enrico-sorichetti » Thu Sep 10, 2015 3:57 pm

if as reported by the TS
Dates are in DD.MM.YYYY format.
in a fixed position

why complicate things ?

Code: Select all

SORT FIELDS=(year_start_column,4,CH,A,month_start_column,2,CH,A,day_start_column,2,CH,A)
should be more than enough


cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)


William Collins
Global Moderator
Global Moderator
Posts: 499
Joined: Sun Aug 25, 2013 7:24 pm

Re: SORT records on date.

Post by William Collins » Thu Sep 10, 2015 4:07 pm

The sample data shown is 31.1.1998, 2.12.1997, 3.6.2014. Hence the need to PARSE (assuming the data shown is correct and the description of the data is not, strictly).



Previous topicNext topic

Return to “SyncSort, SyncTool, SyncGener.”