|
|
| Author |
Message |
Aneesh
New User
Joined: 30 Sep 2006 Posts: 49
|
|
|
|
Hi,
I have 2 files FB of length 5 bytes each. I want to create an output file that has the cross join of all records from the first file to the second.
Input file 1
11111
22222
33333
Input file 2
AAAAA
BBBBB
Output file
11111AAAAA
11111BBBBB
22222AAAAA
22222BBBBB
33333AAAAA
33333BBBBB
Can this be done using sort?
Thanks in advance,
Aneesh. |
|
| Back to top |
|
 |
References
|
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 13611 Location: 221 B Baker St
|
|
|
|
Hello,
No.
What you want to do is a cartesian join.
The last several times this was asked (searching this dfsort part of the forum will find these topics), the answer from IBM was that
| Quote: |
DFSORT does not have a built-in function to do a cartesian join.
|
|
|
| Back to top |
|
 |
Skolusu
DFSORT Developer
Joined: 07 Dec 2007 Posts: 961 Location: San Jose
|
|
|
|
Aneesh,
The following JCL will give you the desired results. I assumed that your input 2 has just 2 records and you are interested in only the first 5 bytes. If you have more records in your file2 , the output will be huge.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AAAAA
BBBBB
//SORTOUT DD DSN=&&S1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//SYSIN DD *
OPTION COPY,STOPAFT=2
OUTREC BUILD=(C'SYM',SEQNUM,1,ZD,C',C''',1,5,C'''',80:X)
/*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=SHR
//SORTIN DD *
11111
22222
33333
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL BUILD=(1,5,SYM1,/,1,5,SYM2)
/* |
|
|
| Back to top |
|
 |
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 4259 Location: Atlanta, GA
|
|
|
|
SAS PROC SQL without a WHERE clause will do a Cartesian join (every record in file 1 will be matched to every record in file 2, yielding output of the number of records in file 1 times the number of records in file 2).
Googling SAS Cartesian join will get over 14,000 hits including some good explanations of the process. |
|
| Back to top |
|
 |
Skolusu
DFSORT Developer
Joined: 07 Dec 2007 Posts: 961 Location: San Jose
|
|
|
|
Aneesh,
With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707, you can use the Joinkeys function like shown below to get the desired results. Since both files don't have a common key we add an extra byte at pos 6 using INREC for each file via JNF1CNTL and JNF2CNTL and use that as a key for matching
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DSN=Your input 5 byte file1,DISP=SHR
//SORTJNF2 DD DSN=Your input 5 byte file2,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILE=F1,FIELDS=(6,1,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(6,1,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,5,F2:1,5)
//JNF1CNTL DD *
INREC BUILD=(1,5,X)
//JNF2CNTL DD *
INREC BUILD=(1,5,X)
//* |
For complete details on Joinkey functions and the other new functions available with the Nov, 2009 DFSORT PTF, see:
http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000174 |
|
| Back to top |
|
 |
|
|
|