Search for a string using SORT #2

  • Permalink
  • submit to reddit
  • Email
  • Follow


To Search for a particular string within a file when the exact position
of that string within a record is not known and to write that record in
the Output file the following SORT card can be used.

Example 1:
SORT FIELDS=COPY
INCLUDE COND= (1, 80, SS, EQ, C'FIND STRING')

Here,

SS - Sub string,
1 - Starting position of the range
80 - Width of the search range
EQ - Comparison operators

The Sort card for this will need information like range of columns
within which you want the search to be performed. To search in the
whole file you can give the start position as 1 and LRECL of the file
as the width of the search range as done above. We can also replace the
'EQ' parameter by 'NE' which will fetch us all the records which don't
have the specified string. Only EQ & NE can be used for comparison. We
can even use OMIT COND instead of INCLUDE.

This can also be used to find the records with string that match one of
the strings in the COND.

Example 2:
SORT FIELDS=COPY
INCLUDE COND= (1, 80, SS, EQ, C'HDR,TRL')

The above sort card returns all records with the substring ' HDR' or
'TRL' occurring within the search range(1-80) of the record in the
input file. 
 
Thanks,
MFTIPS
http://mftips.blogspot.com/

0
Reply mftips (9) 2/8/2006 2:32:03 AM

See related articles to this posting


mftips@gmail.com wrote:
> To Search for a particular string within a file when the exact position
> of that string within a record is not known and to write that record in
> the Output file the following SORT card can be used.
>...

Your examples are actually incorrect.  Your control statements contain
blanks that will result in syntax errors.  For example 1, the INCLUDE
statement should be:

   INCLUDE COND=(1,80,SS,EQ,C'FIND STRING')

Your second example does NOT do what you say it does.

   INCLUDE COND=(1,80,SS,EQ,C'HDR,TRL')

will actually include records with the string 'HDR,TRL' in them.  To
include records with the string 'HDR' or the string 'TRL' in them, you
would use this DFSORT INCLUDE statement:

   INCLUDE COND=(1,80,SS,EQ,C'HDR',OR,
                1,80,SS,EQ,C'TRL')

To include records with the string 'HDR' or the string 'TRL' in
positions 11-13, you could use this DFSORT INCLUDE statement:

   INCLUDE COND=(11,3,SS,EQ,C'HDR,TRL')

For those who are not familiar with DFSORT and DFSORT's ICETOOL, I'd
suggest reading through "z/OS DFSORT:  Getting Started".  It's an
excellent tutorial, with lots of examples, that will show you how to
use DFSORT, DFSORT's ICETOOL and DFSORT Symbols.  You can access it
online, along with all of the other DFSORT books, from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html

Frank Yaeger - DFSORT Team  (IBM) - yaeger@us.ibm.com
Specialties: ICETOOL, IFTHEN, OVERLAY, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/

0
Reply yaeger (25) 2/9/2006 5:51:29 PM

mftips@gmail.com wrote:
> To Search for a particular string within a file when the exact position
> of that string within a record is not known and to write that record in
> the Output file the following SORT card can be used.
>...

Your examples are actually incorrect.  Your control statements contain
blanks that will result in syntax errors.  For example 1, the INCLUDE
statement should be:

   INCLUDE COND=(1,80,SS,EQ,C'FIND STRING')

Your second example does NOT do what you say it does.

   INCLUDE COND=(1,80,SS,EQ,C'HDR,TRL')

will actually include records with the string 'HDR,TRL' in them.  To
include records with the string 'HDR' or the string 'TRL' in them, you
would use this DFSORT INCLUDE statement:

   INCLUDE COND=(1,80,SS,EQ,C'HDR',OR,
                1,80,SS,EQ,C'TRL')

To include records with the string 'HDR' or the string 'TRL' in
positions 11-13, you could use this DFSORT INCLUDE statement:

   INCLUDE COND=(11,3,SS,EQ,C'HDR,TRL')

For those who are not familiar with DFSORT and DFSORT's ICETOOL, I'd
suggest reading through "z/OS DFSORT:  Getting Started".  It's an
excellent tutorial, with lots of examples, that will show you how to
use DFSORT, DFSORT's ICETOOL and DFSORT Symbols.  You can access it
online, along with all of the other DFSORT books, from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html

Frank Yaeger - DFSORT Team  (IBM) - yaeger@us.ibm.com
Specialties: ICETOOL, IFTHEN, OVERLAY, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/

0
Reply yaeger (25) 2/9/2006 5:51:33 PM

On 9 Feb 2006 09:51:33 -0800, yaeger@us.ibm.com wrote:

>For those who are not familiar with DFSORT and DFSORT's ICETOOL, I'd
>suggest reading through "z/OS DFSORT:  Getting Started".  It's an
>excellent tutorial, with lots of examples, that will show you how to
>use DFSORT, DFSORT's ICETOOL and DFSORT Symbols.  You can access it
>online, along with all of the other DFSORT books, from:
>
>www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
>
>Frank Yaeger - DFSORT Team  (IBM) - yaeger@us.ibm.com
>Specialties: ICETOOL, IFTHEN, OVERLAY, Symbols, Migration
>=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/


What happened to
HTTP://PUBLIBZ.BOULDER.IBM.COM/CGI-BIN/BOOKMGR_OS390/BOOKS/ISPZU220/APPENDIX1
?
0
Reply howard (6275) 2/9/2006 5:59:43 PM

Howard Brazee wrote:
> What happened to
> HTTP://PUBLIBZ.BOULDER.IBM.COM/CGI-BIN/BOOKMGR_OS390/BOOKS/ISPZU220/APPENDIX1
> ?

Howard,

Sorry, but I don't understand your question.  Are you looking for an
Appendix in a specific DFSORT book?  If so, which Appendix in which
book?  If not, please clarify.

Frank Yaeger - DFSORT Team  (IBM) - yaeger@us.ibm.com
Specialties: ICETOOL, IFTHEN, OVERLAY, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/

0
Reply yaeger (25) 2/9/2006 6:09:16 PM

On 9 Feb 2006 10:09:16 -0800, yaeger@us.ibm.com wrote:

>> What happened to
>> HTTP://PUBLIBZ.BOULDER.IBM.COM/CGI-BIN/BOOKMGR_OS390/BOOKS/ISPZU220/APPENDIX1
>> ?
>
>Howard,
>
>Sorry, but I don't understand your question.  Are you looking for an
>Appendix in a specific DFSORT book?  If so, which Appendix in which
>book?  If not, please clarify.

I had it as a link written in as documentation for a job.  It no
longer points to anything and I want to update my documentation with
wherever that old documentation was moved to.   Trouble is, I don't
remember what it said.
0
Reply howard (6275) 2/9/2006 6:34:23 PM

Howard Brazee wrote:
> On 9 Feb 2006 10:09:16 -0800, yaeger@us.ibm.com wrote:
>
> >> What happened to
> >> HTTP://PUBLIBZ.BOULDER.IBM.COM/CGI-BIN/BOOKMGR_OS390/BOOKS/ISPZU220/APPENDIX1
> I had it as a link written in as documentation for a job.  It no
> longer points to anything and I want to update my documentation with
> wherever that old documentation was moved to.   Trouble is, I don't
> remember what it said.

Sorry, I don't know what that used to point to so I can't help.

If you're looking for the DFSORT books, you can access them all from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html

Frank Yaeger - DFSORT Team  (IBM) - yaeger@us.ibm.com
Specialties: ICETOOL, IFTHEN, OVERLAY, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/

0
Reply yaeger (25) 2/10/2006 5:40:41 PM
comp.lang.cobol 4201 articles. 4 followers. Post

6 Replies
379 Views

Similar Articles

[PageSpeed] 30


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Search for a string using SORT
To Search for a particular string within a file when the exact position of that string within a record is not known and to write that record in the Output file the following SORT card can be used. Example 1: SORT FIELDS=COPY INCLUDE COND= (1, 80, SS, EQ, C'FIND STRING') Here, SS - Sub string, 1 - Starting position of the range 80 - Width of the search range EQ - Comparison operators The Sort card for this will need information like range of columns within which you want the search to be performed. To search in the whole file you can give the start position as 1 and LRECL of the fil...

sorting strings using 2 criteria
hi all, suppose i have following set of strings : 'f13' 'g12' 'g13' 'h12' 'j12' 'j13' 'k12' 'm12' 'm13' 'm15' 'n12' 'q12' 'u12' 'v12' 'x12' 'z12' 'z13' 'z14' 'z15' 'z16' 'z17' 'z19' i would like to sort them according to following 2 rules: 1. letters should be in this order F G H J K M N Q U V ...

Using Unix sort command to sort on 2 fields
I am attempting to sort a CSV file by 2 fields (sort the 1st field ascending ASCII and then sort the 7th field by descending numeric). The command I've tried after reading extensively the man pages is sort -t, -o PSASort1.dat +0 -1 -n -r +6 -7 PSATst1.csv I assumed this would (1) use "," as the input separator, (2) write the sorted output to PSASort1.dat, (3) sort in ascending order the first field in the record, and then (4) sort in descending (-r) numeric order (-n) the 7th field in the record. In fact this sorted only the 7th field in the record in descending numeric ord...

searching an array, string compare functions, string sorting
Hello, I would like to use an array as a search index. The code defining the array is not generated with JavaScript. When searching a word in the index, I do a quick binary search. Which fails, of course, if the order of the words in the array is not in exactly the way as JavaScript would sort them. The words in the index can contain special characters, e.g. from the german, french or spanish alphabet. I wonder what might be easier: To teach the external application to sort the index array in a way that equals the JavaScript sorting, OR to teach JavaScript to compare strings in a way that ...

Re: How to find out duplicates by using sql (Not using proc sort #2
On Tue, 1 Jul 2008 05:36:20 -0700, ravikumarpsas@GMAIL.COM wrote: >Hi, > >I am Ravi kumar. >I have a simple question. >data a; >input x; >cards; >2 >6 >2 >9 >6 >; >run; >For the above question,How to findout the duplicates by using sql. >output: >2 >6 >Please help me on the same >Many Thanks >Ravi proc sql; select x from a group by x having count('x') > 1; quit; ...

String search #2
Hi, Iam new to tcl. Iam writing a simple script to search a string starting with '0' and get that string and assign that string to a variable so that I can use it for future. The main string is like this s:/dest/file/forward/0342_uid_forward_gu.90w I want to search for the substring starting with '0', and assign that to a variable. Please help me. Tanks in advance. Regards, Kukku. kukkus1234@rediffmail.com wrote: > > Hi, > > Iam new to tcl. Iam writing a simple script to search a string starting > with '0' and get that string and assign that ...

Search for 2 strings
Hi I have a file containing 2 words on 2 seperate lines: e.g. car bike I want to pipe this file through sed or awk, and only return the output only **both** words are found. Could someone help me do this? As they are on different lines grep wont work. Thanks On Wed, 11 Aug 2010 10:26:47 -0700 (PDT) Chris <cconnell_1@lycos.com> wrote: > Hi > I have a file containing 2 words on 2 seperate lines: > > e.g. > > car > bike > > I want to pipe this file through sed or awk, and only return the > output only **both** words are found. C...

Chris Pine tutorial assistance chapter 7 sort data without use of .sort method #2
I'm learning to program and came across Chris Pine's Ruby Tutorial. I've got to the Array and Iterators chapter ( http://pine.fm/LearnToProgram/?Chapter=07 ). and the following assignment " Let's write a program which asks us to type in as many words as we want (one word per line, continuing until we just press Enter on an empty line), and which then repeats the words back to us in alphabetical order. OK? " ****** HOWEVER I'm not allowed to use the .sort method ******** The covered chapters (1 ~ 7) have not covered method creation, Classes, Blocks or Procs, so...

write in 2 columns using a &quot;write to spreadsheet file&quot; if I have 2 strings which are in columns
I have tried, but I don't know how to do it Thanks Duplicate <a href="http://forums.ni.com/ni/board/message?board.id=170&amp;message.id=249412&amp;jump=true" target="_blank">thread</a> Please stick to one thread ...

string search on grep #2
Hello, do you know how to exclude a string from grep result? Basically, I don't want a certain word in the greped output, but it seems there is not document online about this. Does anyone know how to do this. Thank you very much. Regards, Jian On Wed, 04 Apr 2007 05:36:28 -0700, jian wrote: > Hello, do you know how to exclude a string from grep result? > Basically, I don't want a certain word in the greped output, but it > seems there is not document online about this. Does anyone know how to > do this. Thank you very much. > > Regards, > Jian Hi Jian, try t...

How would you use qsort to sort on a string
I'm curious if you can easily use qsort to sort the letters in a null terminated string, without using any conditional statements? char str[ ] = "bdace"; becomes "abcde" "Eddy C" <eddy73@gmail.com> writes: > I'm curious if you can easily use qsort to sort the letters in a null > terminated string, without using any conditional statements? > > char str[ ] = "bdace"; > > becomes "abcde" The following is not compiled or well proofread. It will only produce the desired output for your example on systems where ...

searching strings using variables
Hi, all. Another bewildered newbie struggling with Python goodness. This time it's searching strings. The goal is to search a string for a value. The string is a variable I assigned the name 'myvar'. however, it doesn't seem to be seeing it... Here's a snippet. import re # list of items to search... mylist = [ 5 , 6 , 16 , 17 , 18 , 19 , 20 , 21 ] # my variable I want to search with... myvar = '16' print re.search('myvar','mylist') .... just returns none. Tried it also with... mylist.index('myvar') to see if I could spook it out but I...

Re: search string #2
Hello M M Scanning a string for a character ... I would use substr() function ... the rest depends on your desired output. Two different out-s below.. HTH Magnus --------------- begin code --------------- data in ; input string $ 1-25; cards; ----+-+-+----+ --+---------+- ------++---+-+ ; run; data out_1; set in; length pos $ 100; do i = 1 to length(string); if (substr(string, i, 1) = '+') then pos = trim(left(pos)) || ';' || put(i, 8.-L); end; keep string pos; run; data out_2; set in; do pos = 1 to length(string); if (substr...

Sorting by using parts of a string
Hi, This is a tougher one, but I'm quite sure someone will have a solution for this. Of course, a last minute thing thrown at me by my boss. I have a unique identifier consisting of regions, districts, a road class value and then sequential numbers, in that order, eg: GA-GAD-C-005 The thing is that the sequential values don't follow onto each other as it does the sorting on the road class value first (which could be A, I or C). So, you'll have the first three parametres correct, but the number skips values, which appears in a different "group" for that district. I n...

Searching a sorted array of strings
Hi All- I am an infrequent user of Perl. I sat down this morning to do a simple task, which started with referring to some data. It took me a while to write this simple routine, making most every mistake on the way. Perhaps it will be useful to someone. I tried to use qw( "name" "name space" ); and had problems, so I use the long form. Constructive comments welcome. The array is almost a thousand elements actually, edited for usenet <- snip -> #! /usr/bin/perl -w use strict; use warnings; my @CA_Cities = ( "adelanto", "agoura hills",...

Search string in Array #2
I have one 1D array in that array the elements are started like 04_02_26LS1004(format is yy_mm_ddserialnumber).I Dont know the array size. It may go more than 60000. I want to search the elements which are all matching for the first 8 characters(yy_mm_dd).I don't need to compare one element by one element using for loop.Please Suggest. with regards R.sathiyanarayanan You could sort the array, and then do a binary search for 04_02_26AA0000 (lowest possible according to ASCII table) and 04_02_26zz9999 (highest possible according to ASCII table) which should represent the lower and upper r...

doc on searching, and sorting #2
This is a multi-part message in MIME format. ------=_NextPart_000_005D_01C36B04.E30D3280 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I'm looking for a good treatment of searching through tables in PostgreSQL.= I've read the doc, so I can build searches using LIKE/SIMILAR TO/~ , but i= t would be really useful if I could read up on strategies for executing que= ries (both for good results, and for efficiency).=20 In the absence of that, I'm currently trying to figure out if it is feasibl= e to sort my ma...

Re: string search #2
Look at the VERIFY function. On Fri, 20 Aug 2004 16:29:32 -0700, Max503 <max8ca@YAHOO.COM> wrote: >Hello, > >I tried to do a string search using > >substr(number, 1, 3) >='AAA' and substr(number, 1, 3) <= 'PBS' from > > >ABD >A32 >ABG >A21 > >etc. > >Howerver, what returned included 'A21', 'A32'. Why the three letter >string contained numbers? I need to exclude anything with a number in >it. Thanks. > > >Max ...

For a mid priced range used clothing shopping experience, search resale shops in your area. Resale shops offer all price ranges for used clothing and are often more organized than a flea marke #2
For a mid priced range used clothing shopping experience, search resale shops in your area. Resale shops offer all price ranges for used clothing and are often more organized than a flea market or thrift store. Be sure to have your children try the clothes on since many of these stores do not allow for returns. http://www.shoesbootjeans.com http://www.shoesbootjeans.com/Replica_Mens%20Shoes_1.html http://www.shoesbootjeans.com/Replica_Womens%20Shoes_1.html http://www.shoesbootjeans.com/Replica_Boots_1.html http://www.shoesbootjeans.com/Replica_Boots_1.html http://www.shoesbootjeans.com/newarr...

search perldocs against each word in a string #2
#!/usr/bin/perl #file: pdoc.pl searches perldocs use warnings; use strict; pdoc.pl "perldoc individual words string" output: perl5005delta perl561delta perl581delta perlmodlib perlos2 perlport Is there anything built in that does this? It runs pretty fast considering it has to load each perldoc into memory and compare against each word in search string. use File::Slurp; use File::Find; #file: pdoc.pl: search perldocs my $string = $ARGV[0]; my @string = split /\s+/, $string; my $count = scalar @string; my $path = 'c:\perl\lib\pod'; find(\&wanted, $path); sub wanted { m...

Using C for string search etc
I have a set of huge files on which I am doing some typical search and replace operations, with the help of sed/awk scripts. However for various reasons I have to write C programs instead of sed/awk scripts. If someone has experience with C programming with string searches, replace etc please let me know, web links, pointers etc. brian <brian_dell3@yahoo.com> spoke thus: > However for various reasons I have to write C programs instead of > sed/awk scripts. If someone has experience with C programming with > string searches, replace etc please let me know, web links, pointers ...

search for a string in a file using expect..
Hi, I want to grep for a particular string in a file and get the value next to it. My data: user1: 11111111 user2: 22222222 code ====== set in [open "data.txt" r] while {[gets $in line] != -1} { # here i want to grep for user2 and get the value 11111111 as out put. } close $in Sooraj S wrote: > Hi, > I want to grep for a particular string in a file and get the value > next to it. > > My data: > user1: 11111111 > user2: 22222222 > > code > ====== set in [open "data.txt" r] while {[gets $in line] >= ...

How do I use a variable in a regexp search string?
Hi All, I dont know how to use a variable in a regex searchstring. ruby seems to only handle hardcoded serachstring in regex's. How do you do this. My code is below. Also - how do you put a variable name in a File.open("filename.txt") statement like this: File.open(filevariable) where filevariable can be set to anything? I could not find this in the docs. Thanks, --Joe ================ snip code =============== #!/usr/bin/ruby F = "filename.txt" searchstring = ARGV[0] print "searchstring is ", searchstring, "\n" F...

searching for 2 patterns using grep
Okay, I may be missing something pretty basic here but how do I grep a file for the existance of 2 patterns on a line? I can use grep -E 'pattern1|pattern2' file and if pattern1 or pattern2 exist on the line then it will display it. What I want to do is grep and only return the line when pattern1 AND pattern2 are found. Help me ?? anthony wrote: > Okay, I may be missing something pretty basic here but how do I grep a > file for the existance of 2 patterns on a line? > I can use grep -E 'pattern1|pattern2' file and if pattern1 or pattern2 > exist on the line then ...