Page 1 of 1

SyncSort Sort on Substring of PD

PostPosted: Tue Jul 08, 2008 7:37 pm
by dcourn
Hello All,

I have a file with RECFM=VB and LRECL=604. In position 173, length 6, format PD, I have a 10-digit number. I would like to select all observations for which the first 7 digits of that number are, say, 1234567. I want to keep all the original variables in the newly created file (i.e. have the same file, but only with observations that correspond to the condition I specify).

I know there is a substring comparison option in SyncSort, but I believe this only works if you want to compare characters.

Possible solutions that come to mind would be:

1) Create a length-10 character string at the end of each record, with the PD variable reformatted as character. Then use the substring comparison tool
2) Create a length-10 numeric string at the end of each record, with the PD variable reformatted as numeric. Then take the integer of that number divided by 1000, which would give me the first 7 digits

However, I am unsuccessful at either. My attempt at the first solution was to use an INREC statement such as:

INREC FIELDS=(1:173,6,PD,CH)

and then use an INCLUDE COND= statement, but I get a "WER268A INREC STATEMENT : SYNTAX ERROR" on the INREC statement.

Please note that I am using SYNCSORT FOR Z/OS, 1.3.0.0R.

Thank you in advance for your help,

Daniel

Re: SyncSort Sort on Substring of PD

PostPosted: Tue Jul 08, 2008 10:11 pm
by dick scherrer
Hello Daniel and welcome to the forums,

If your packed-decimal field looks like this:
....5.
024646
13575C

containing the value 1234567456,
you could check for x'01234567' to select those records beginning with 1234567. . .

Re: SyncSort Sort on Substring of PD

PostPosted: Tue Jul 08, 2008 10:29 pm
by dcourn
dick scherrer wrote:Hello Daniel and welcome to the forums,


Thank you very much Dick :)

Is what you are suggesting something that looks like the following:

//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(173,6,PD,EQ,x'01171618')

?

I have tried this but without success, getting the following message:

SYSIN :
SORT FIELDS=COPY
INCLUDE COND=(173,6,PD,EQ,x'01171618')
*
WER161B ALTERNATE PARM USED
WER268A INCLUDE STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE

My packed decimal field looks like this:

011102
17680F

(in this case, the 10-digit number is 1171618002)

Perhaps I did not apply or understand your suggestion correctly? If that is the case, might I ask you to point out what my mistake is?

Thank you,

Daniel

Re: SyncSort Sort on Substring of PD

PostPosted: Tue Jul 08, 2008 11:33 pm
by dick scherrer
Hi Daniel,

You would specify the field as character rather than pd and use a length of 4 rather than 6 (you only want to compare the high-order 4 bytes - skipping the last 3 digits and the sign if i understood the question).

Re: SyncSort Sort on Substring of PD

PostPosted: Wed Jul 09, 2008 1:23 am
by dcourn
Thank you very much Dick!

I had originally used a small caps "x" which did not work, but I got the results I was expecting with a capital X :D

Now that I know what to look for, I'll give the SyncSort manual a newly enlightened read and try to understand what is happening here!

Many thanks for your help!

Daniel

Re: SyncSort Sort on Substring of PD

PostPosted: Wed Jul 09, 2008 1:29 am
by dick scherrer
Hi Daniel,

You're welcome :)

If you have the newest (1.3) manual, you might also look for "pdo" as a datatype.

I am not sure, but this may also be in the new release.It would be a bit more elegant to do what you want.