Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sortcard to put comma after particular word
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 159
Location: India

PostPosted: Mon May 11, 2015 8:20 pm    Post subject: Sortcard to put comma after particular word
Reply with quote

Hi,

I have below requirement like

dataset like below:

Code:


A,                ,C,D1 D2 D3,E,F
     B1 IN                           F
     B2 IN                           F
     B3 OUT                          F



Expected out dataset:

Code:


A,B1 IN B2 IN,B3 OUT,C,D1 D2 D3,E,F



Can some one please help me what kind of sort card do i need to use to get my expected output.


Thanks

[/code]
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon May 11, 2015 8:23 pm    Post subject: Reply to: search the last word using jcl
Reply with quote

Which SORT product do you have?

What RECFM and LRECL? Is the input always a fixed structure like that?

How does what you wrote relate to the title you gave it?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1712
Location: UK

PostPosted: Mon May 11, 2015 8:25 pm    Post subject:
Reply with quote

And if you want a sort solution why post int the JCL section of the forum instead of the appropriate sort section?
Back to top
View user's profile Send private message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 159
Location: India

PostPosted: Mon May 11, 2015 8:42 pm    Post subject:
Reply with quote

sorry for the wrong kind of info,

my input dataset is


Code:



A,B1 IN B2 IN B3 OUT,C,D1 D2 D3,E,F




expected output:

Code:


A,B1 IN B2 IN,B3 OUT,C,D1 D2 D3,E,F




commma(,) should be added after the last IN where the column position of last IN may vary.

can you please help me in thi... we ue syncsort and DFsort
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon May 11, 2015 8:54 pm    Post subject: Reply to: search the last word using jcl
Reply with quote

Will the number of INs vary, or will there always be two?
Back to top
View user's profile Send private message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 159
Location: India

PostPosted: Mon May 11, 2015 9:11 pm    Post subject: Re: Reply to: search the last word using jcl
Reply with quote

Bill Woodger wrote:
Will the number of INs vary, or will there always be two?



it will always be 2.but the column position will vary like sometimes it may be in 32 or sometime or where else..... so should find the last IN in the record.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon May 11, 2015 9:45 pm    Post subject: Reply to: Sortcard to put comma after particular word
Reply with quote

Use INREC with IFTHEN=(WHEN=INIT and FINDREP to change C' IN ' to (an example X'FFFFFFFF' use DO=1, very important, so that only the first is changed. Then another WHEN=INIT with FINDREP to make the change you want to the second IN (now the first), again with DO=1. Finally, a third WHEN=INIT and FINDREP to change X'FFFFFFFF' back to C' IN '.
Back to top
View user's profile Send private message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 159
Location: India

PostPosted: Tue May 12, 2015 11:27 am    Post subject: Re: Reply to: Sortcard to put comma after particular word
Reply with quote

Bill Woodger wrote:
Use INREC with IFTHEN=(WHEN=INIT and FINDREP to change C' IN ' to (an example X'FFFFFFFF' use DO=1, very important, so that only the first is changed. Then another WHEN=INIT with FINDREP to make the change you want to the second IN (now the first), again with DO=1. Finally, a third WHEN=INIT and FINDREP to change X'FFFFFFFF' back to C' IN '.


But I want only the last IN to be added with comma...not all IN's.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue May 12, 2015 11:42 am    Post subject: Reply to: Sortcard to put comma after particular word
Reply with quote

Really? And what happened when you coded up and tested my suggestion?

Are you now sure that there will always be two as you stated earlier?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue May 12, 2015 12:12 pm    Post subject: Reply to: Sortcard to put comma after particular word
Reply with quote

Use INREC with IFTHEN=(WHEN=INIT and FINDREP to change C' IN ' to (an example X'FFFFFFFF' use DO=1, very important, so that only the first is changed.

Code:
OPTION COPY

INREC IFTHEN=(WHEN=INIT,
                FINDREP=(IN=C' IN ',
                       OUT=X'FFFFFFFF',
                       DO=1))


Then another WHEN=INIT with FINDREP to make the change you want to the second IN (now the first), again with DO=1.

Code:
OPTION COPY

INREC IFTHEN=(WHEN=INIT,
                FINDREP=(IN=C' IN ',
                       OUT=X'FFFFFFFF',
                       DO=1)),
      IFTHEN=(WHEN=INIT,
                FINDREP=(IN=C' IN ',
                       OUT=C' IN,',
                       DO=1))



Finally, a third WHEN=INIT and FINDREP to change X'FFFFFFFF' back to C' IN '.

Code:
OPTION COPY

INREC IFTHEN=(WHEN=INIT,
                FINDREP=(IN=C' IN ',
                       OUT=X'FFFFFFFF',
                       DO=1)),
      IFTHEN=(WHEN=INIT,
                FINDREP=(IN=C' IN ',
                       OUT=C' IN,',
                       DO=1)),
      IFTHEN=(WHEN=INIT,
                FINDREP=(OUT=C' IN ',
                       IN=X'FFFFFFFF',
                       DO=1))


Run each of those with this as the input, so you can understand what is happening:

Code:
 IN  IN  IN  IN  IN  IN
Back to top
View user's profile Send private message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 159
Location: India

PostPosted: Tue May 12, 2015 6:04 pm    Post subject: Re: Reply to: Sortcard to put comma after particular word
Reply with quote

Bill Woodger wrote:
Use INREC with IFTHEN=(WHEN=INIT and FINDREP to change C' IN ' to (an example X'FFFFFFFF' use DO=1, very important, so that only the first is changed.

Code:
OPTION COPY

INREC IFTHEN=(WHEN=INIT,
                FINDREP=(IN=C' IN ',
                       OUT=X'FFFFFFFF',
                       DO=1))


Then another WHEN=INIT with FINDREP to make the change you want to the second IN (now the first), again with DO=1.

Code:
OPTION COPY

INREC IFTHEN=(WHEN=INIT,
                FINDREP=(IN=C' IN ',
                       OUT=X'FFFFFFFF',
                       DO=1)),
      IFTHEN=(WHEN=INIT,
                FINDREP=(IN=C' IN ',
                       OUT=C' IN,',
                       DO=1))



Finally, a third WHEN=INIT and FINDREP to change X'FFFFFFFF' back to C' IN '.

Code:
OPTION COPY

INREC IFTHEN=(WHEN=INIT,
                FINDREP=(IN=C' IN ',
                       OUT=X'FFFFFFFF',
                       DO=1)),
      IFTHEN=(WHEN=INIT,
                FINDREP=(IN=C' IN ',
                       OUT=C' IN,',
                       DO=1)),
      IFTHEN=(WHEN=INIT,
                FINDREP=(OUT=C' IN ',
                       IN=X'FFFFFFFF',
                       DO=1))


Run each of those with this as the input, so you can understand what is happening:

Code:
 IN  IN  IN  IN  IN  IN




I tried with the code and the input which you mentioned. In the last code I get the output with comma included in the second position.

but what if my input is something like below :

Code:

 
IN  IN  IN   OUT  OUT  OUT



I want my output like below:

Code:


IN  IN  IN,  OUT  OUT  OUT

Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue May 12, 2015 6:21 pm    Post subject: Reply to: Sortcard to put comma after particular word
Reply with quote

Swathi Muralidharan wrote:
Bill Woodger wrote:
Will the number of INs vary, or will there always be two?



it will always be 2.but the column position will vary like sometimes it may be in 32 or sometime or where else..... so should find the last IN in the record.


That's why I asked.

So, will it always be two as you said when asked, or will it sometimes be other than two (like one, three, any amount greater than three)? If so, what are the rules for it?
Back to top
View user's profile Send private message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 159
Location: India

PostPosted: Tue May 12, 2015 6:34 pm    Post subject: Re: Reply to: Sortcard to put comma after particular word
Reply with quote

Bill Woodger wrote:
Swathi Muralidharan wrote:
Bill Woodger wrote:
Will the number of INs vary, or will there always be two?



it will always be 2.but the column position will vary like sometimes it may be in 32 or sometime or where else..... so should find the last IN in the record.


That's why I asked.

So, will it always be two as you said when asked, or will it sometimes be other than two (like one, three, any amount greater than three)? If so, what are the rules for it?



I thought you are asking about the length. My mistake very sorry....yeah it may occur many times not constant like for example in the dataset in first line of records there may be two IN and in the second line record there might be three or even more than that.

Example:

Code:


jobname1 IN  jobname2 IN  jobname3 IN jobname4 OUT
jobname1 IN  jobname2 IN  jobname3 OUT



Expected output :

Code:


jobname1 IN jobname2 IN  jobname3 IN, jobname4 OUT
jobname1 IN jobname3 IN, jobname3 OUT



In my expected output the comma should be included after the last IN condition.

Thanks,
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue May 12, 2015 7:27 pm    Post subject: Reply to: Sortcard to put comma after particular word
Reply with quote

OK, now that we've securely established that IN contains two characters...

"Last" is tricky. So I'm going to suggest you rearrange your data so that it is the first.
Code:

  OPTION COPY
                                                                       
  INREC IFTHEN=(WHEN=INIT,
           BUILD=(12,1,11,1,10,1,9,1,8,1,7,1,6,1,5,1,4,1,3,1,2,1,1,1)),
        IFTHEN=(WHEN=INIT,
                FINDREP=(IN=C' NI ',
                       OUT=C',NI ',
                       DO=1)),
        IFTHEN=(WHEN=INIT,
           BUILD=(12,1,11,1,10,1,9,1,8,1,7,1,6,1,5,1,4,1,3,1,2,1,1,1))
//SORTIN   DD *
 IN  IN  IN
 IN  IN
 IN
 OUT


That produces:

Code:
 IN  IN  IN,
 IN  IN,   
 IN,       
 OUT   


That's an example with 12 bytes of data. You can do the typing for your length of data. Now you're going to tell us they are variable-length records?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1712
Location: UK

PostPosted: Tue May 12, 2015 10:02 pm    Post subject:
Reply with quote

Are you sure it is
Quote:
after a particular word
- in this case IN and not
Quote:
before a particular word
- in this case OUT ,which is what it appears to be from the latest example? Does that make it easier?
Back to top
View user's profile Send private message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 159
Location: India

PostPosted: Tue May 12, 2015 11:17 pm    Post subject: Re: Reply to: Sortcard to put comma after particular word
Reply with quote

Bill Woodger wrote:
OK, now that we've securely established that IN contains two characters...

"Last" is tricky. So I'm going to suggest you rearrange your data so that it is the first.
Code:

  OPTION COPY
                                                                       
  INREC IFTHEN=(WHEN=INIT,
           BUILD=(12,1,11,1,10,1,9,1,8,1,7,1,6,1,5,1,4,1,3,1,2,1,1,1)),
        IFTHEN=(WHEN=INIT,
                FINDREP=(IN=C' NI ',
                       OUT=C',NI ',
                       DO=1)),
        IFTHEN=(WHEN=INIT,
           BUILD=(12,1,11,1,10,1,9,1,8,1,7,1,6,1,5,1,4,1,3,1,2,1,1,1))
//SORTIN   DD *
 IN  IN  IN
 IN  IN
 IN
 OUT


That produces:

Code:
 IN  IN  IN,
 IN  IN,   
 IN,       
 OUT   


That's an example with 12 bytes of data. You can do the typing for your length of data. Now you're going to tell us they are variable-length records?




its not like variable-length records. The IN may appear N number of times any where from column number 700 to 1179....So inbetween these i should find the last IN and put a comma after that...
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed May 13, 2015 12:53 am    Post subject: Reply to: Sortcard to put comma after particular word
Reply with quote

Well, that's great news. You only have to reverse that part (twice). Use STARTPOS and ENDPOS on the FINDREP as well.

Your alternative is PARSE. With IFTHEN=(WHEN=(logicalexpression to then test the PARSED fields to identify which is the last and then change that data and put the record back together again. You'd need a solid limit to the number of INs which can exist, and care when putting the record back together.
Back to top
View user's profile Send private message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 159
Location: India

PostPosted: Wed May 13, 2015 11:59 am    Post subject: Re: Reply to: Sortcard to put comma after particular word
Reply with quote

Bill Woodger wrote:
Well, that's great news. You only have to reverse that part (twice). Use STARTPOS and ENDPOS on the FINDREP as well.

Your alternative is PARSE. With IFTHEN=(WHEN=(logicalexpression to then test the PARSED fields to identify which is the last and then change that data and put the record back together again. You'd need a solid limit to the number of INs which can exist, and care when putting the record back together.



Sorry bill, I couldnt understand the below lines :

Quote:


(WHEN=(logicalexpression to then test the PARSED fields to identify which is the last and then change that data and put the record back together again.

Back to top
View user's profile Send private message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 159
Location: India

PostPosted: Wed May 13, 2015 12:08 pm    Post subject: Re: Reply to: Sortcard to put comma after particular word
Reply with quote

Bill Woodger wrote:
Well, that's great news. You only have to reverse that part (twice). Use STARTPOS and ENDPOS on the FINDREP as well.



Also reversing that part means, you mean the way like you have coded in the above post using BUILD right....? If that is the case it will take almost 300 as it starts from 700 to 1179 which is almost 300 difference. will that be fine, if I do like the above BUILD...?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed May 13, 2015 12:10 pm    Post subject: Reply to: Sortcard to put comma after particular word
Reply with quote

To use the PARSE you'd need to know the maximum number of possible " IN " values, Then you test those PARSEd values, one test for each possible, in reverse order, and do the code to put the data with a comma "back" into the correct position within the current record.

If you're already processing the data in SAS, can't you do it there?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Extra Spaces in a comma sepa... Puspojit DFSORT/ICETOOL 3 Tue Sep 13, 2016 7:46 am
No new posts Select "SECOND WORD" in tex... jackare SYNCSORT 3 Fri Aug 07, 2015 8:17 pm
No new posts FTINCL failure code 20 Invalid contro... Steve Coalbran TSO/ISPF 2 Mon Aug 04, 2014 10:44 am
No new posts Align second word to specific column Stephan Arenswald TSO/ISPF 9 Tue Jul 08, 2014 12:00 pm
No new posts comparing file using sortcard with th... Annie Mary George DFSORT/ICETOOL 3 Fri Jan 24, 2014 10:58 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us