View previous topic :: View next topic
|
Author |
Message |
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi All,
I am running below mentioned sort step:
Code: |
//SORT0010 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SORTIN DD DSN=HLQ1.HLQ2.SX.PA.REGION,
// DISP=SHR,
// DCB=(LRECL=80,RECFM=FB)
// DD DSN=HLQ1.HLQ2.SX.PA.REGION.PD,
// DISP=SHR,
// DCB=(LRECL=80,RECFM=FB)
// DD DSN=HLQ1.HLQ2.SX.VPALORC.PS,
// DISP=SHR,
// DCB=(LRECL=80,RECFM=FB)
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,19,BI,A),FILES=3
RECORD TYPE=F,LENGTH=(80)
//*
|
Data in the input files is
File 1:
Code: |
----+----1----+----2----
0073020193233193233A0000
0073020193233193233B0001
XXXXXBBBBBPPPPPQQQQA0000
XXXXXBBBBBPPPPPQQQQB0001
|
File 2:
Code: |
----+----1----+----2----
XXXXXBBBBBPPPPPQQQQA0003
XXXXXBBBBBPPPPPQQQQB0002
SDFHJKLAHBPPPPPQQQQA0000
SDFHJKLAHBPPPPPQQQQB0001
|
File 3:
Code: |
----+----1----+----2----
0073020193233193233A0004
0073020193233193233B0005
WQEUROQWEI233193233A0000
WQEUROQWEI233193233B0001
|
I was expecting the output as mentioned below:
Code: |
SDFHJKLAHBPPPPPQQQQA0000
SDFHJKLAHBPPPPPQQQQB0001
WQEUROQWEI233193233A0000
WQEUROQWEI233193233B0001
XXXXXBBBBBPPPPPQQQQA0000
XXXXXBBBBBPPPPPQQQQB0001
XXXXXBBBBBPPPPPQQQQA0003
XXXXXBBBBBPPPPPQQQQB0002
0073020193233193233A0000
0073020193233193233B0001
0073020193233193233A0004
0073020193233193233B0005
|
On each run I am getting the output in random sequence.
My output is,
Run 1:
Code: |
SDFHJKLAHBPPPPPQQQQA0000
SDFHJKLAHBPPPPPQQQQB0001
WQEUROQWEI233193233A0000
WQEUROQWEI233193233B0001
XXXXXBBBBBPPPPPQQQQA0003
XXXXXBBBBBPPPPPQQQQA0000
XXXXXBBBBBPPPPPQQQQB0001
XXXXXBBBBBPPPPPQQQQB0002
0073020193233193233A0000
0073020193233193233A0004
0073020193233193233B0005
0073020193233193233B0001
|
Run 2:
Code: |
SDFHJKLAHBPPPPPQQQQA0000
SDFHJKLAHBPPPPPQQQQB0001
WQEUROQWEI233193233A0000
WQEUROQWEI233193233B0001
XXXXXBBBBBPPPPPQQQQA0000
XXXXXBBBBBPPPPPQQQQA0003
XXXXXBBBBBPPPPPQQQQB0001
XXXXXBBBBBPPPPPQQQQB0002
0073020193233193233A0004
0073020193233193233A0000
0073020193233193233B0005
0073020193233193233B0001
|
Please see the last 4 records.
I know that SORT will not assure the order/sequence, but I need my output in the same order.
Can anyone help me out to get the sorted data in the order?
Thanks,
Satish |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
for <duplicate> keys the order is unpredictable,
the only workaround is to use OPTION EQUALS
which will for <duplicate> keys preserve the original relative sequence |
|
Back to top |
|
|
xknight
Active User
Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Hello,
I have tested your snippet, worked for me.
Anyhow try this,
Code: |
//SORT0010 EXEC PGM=ICETOOL
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//IN1 DD DSN=TEST.INPUT.FILE1,DISP=SHR,
// LRECL=80,RECFM=FB
// DD DSN=TEST.INPUT.FILE2,DISP=SHR,
// LRECL=80,RECFM=FB
// DD DSN=TEST.INPUT.FILE3,DISP=SHR,
// LRECL=80,RECFM=FB
//OUT1 DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN1) TO(OUT1) USING(CTL1)
/*
//CTL1CNTL DD *
SORT FIELDS=(1,19,BI,A) |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
xknight wrote: |
[...]
I have tested your snippet, worked for me.
[...] |
Maybe your site has EQUALS as the installation default? |
|
Back to top |
|
|
xknight
Active User
Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Quote: |
Maybe your site has EQUALS as the installation default? |
May be you are correct bill. Suppose it should |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
The default value for the SAS SORT proc is EQUALS.
I think this is a terrible idea. Novices and even some with experience will assume this is standard sort behavior across all sort programs.
I suggest never relying on this as a default value, but rather always specifying EQUALS when you want/need it. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
satish.ms10 wrote: |
[...]
Code: |
SORT FIELDS=(1,19,BI,A),FILES=3
RECORD TYPE=F,LENGTH=(80)
//* |
[...] |
I have to say this is a little odd. I'd have thought FILES=3 would be for a MERGE. The LENGTH is likely going to be ignored, as is the TYPE, or are you reading VSAM? Maybe it is a very old sort deck? |
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi All,
Many Thanks for your kind response.
It worked with OPTION EQUALS.
Thanks Again.
-Sati |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
have to say this is a little odd. I'd have thought FILES=3 would be for a MERGE. The LENGTH is likely going to be ignored, as is the TYPE |
FILES=n is ignored by DFSORT unless you are doing a MERGE with all of the records inserted by an E32 exit.
LENGTH and TYPE will be ignored here also since DFSORT can obtain them from the SORTIN data set. |
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi Frank,
I have removed FILES, LENGTH and TYPE options from the SORT card.
Many Thanks for you suggestion.
Thanks,
Saish |
|
Back to top |
|
|
|