View previous topic :: View next topic
|
Author |
Message |
kalyanp_80
New User
Joined: 03 Feb 2006 Posts: 41 Location: Hyderabad
|
|
|
|
Hi,
While specifying the Include condition for a SORT operation, I want to include only those records for which the last 3 bytes have the value 'CAN', sample records are as below
2007-07-25 Vijay K S Main Street USA
2006-05-06 Narendra M J East Coast CAN
2004-10-12 Arun A K Park Avenue Main Street CAN
2001-05-09 Sam R New Street USA
Since the records are of variable length, how to make sure that only the last 3 bytes are validated for the value 'CAN' for every record?
Thanks,
Amith |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Amith,
You could use format 'SS' to search for a string in the entire record. Search dfsort forum for format SS examples. |
|
Back to top |
|
|
kalyanp_80
New User
Joined: 03 Feb 2006 Posts: 41 Location: Hyderabad
|
|
|
|
Hi Murali,
Thanks for your reply. I will try this option.
Thanks
Amith |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I will try this option |
When you do your testing, i'd suggest using at least one test record that has CAN embedded in the data as well as records with CAN at the end.
I believe any "CAN" will be a "hit", not only in the last 3 bytes. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Dick,
Quote: |
I believe any "CAN" will be a "hit", not only in the last 3 bytes. |
Yes, that would be true with SS.
Quote: |
When you do your testing, i'd suggest using at least one test record that has CAN embedded in the data as well as records with CAN at the end. |
I thought of that and was going to suggest a more foolproof way to do it, but then it occurred to me looking at the data that CAN in uppercase would probably only appear as the last field. So I didn't bother.
Amith,
If CAN can only appear at the end of the record, then these DFSORT control statements would work. I assumed the maximum record length is 80, but the INCLUDE statement can be changed appropriately for a different maximum record length.
Code: |
OPTION COPY,VLSCMP
INCLUDE COND=(1,80,SS,EQ,C'CAN')
|
If CAN can appear elsewhere, then tell me the maximum record length in the input file and I'll show you how to ensure that CAN is only found in the last three bytes. |
|
Back to top |
|
|
|