|
View previous topic :: View next topic
|
| Author |
Message |
vickey_dw
New User
Joined: 10 Jun 2015 Posts: 51 Location: India
|
|
|
|
Hi All,
I need help in one more sort.
My input file is below
| Code: |
Re Insu 123
Re Insu 456
Allcede 123
Allcede 123
Allcede 123
Allcede 123
Allcede 123
Encompa 569
Encompa 458
|
I want to replace the 1st occurence of "Allcede 123" by "Allcede 777",2nd by "Allcede 666" ,3rd occurence by "Allcede 555",4th occurence by "Allcede 444" and 5th occurence by "Allcede 222"".All rest records should be same.
So my output File should be
| Code: |
Re Insu 123
Re Insu 456
Allcede 777
Allcede 666
Allcede 555
Allcede 444
Allcede 222
Encompa 569
Encompa 458 |
I tried Like below
| Code: |
Sort fields=copy
INREC IFTHEN=(WHEN=(1,11,CH,EQ,C'Allcede 123'),OVERLAY=(9:C'777')),
IFTHEN=(WHEN=(1,11,CH,EQ,C'Allcede 123'),OVERLAY=(9:C'666')),
IFTHEN=(WHEN=(1,11,CH,EQ,C'Allcede 123'),OVERLAY=(9:C'555')),
IFTHEN=(WHEN=(1,11,CH,EQ,C'Allcede 123'),OVERLAY=(9:C'444')),
IFTHEN=(WHEN=(1,11,CH,EQ,C'Allcede 123'),OVERLAY=(9:C'222'))
|
But its replacing all "Allcede 123" by "Allcede 777".
Can you please suggest on this. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
Will your input have random occurrences of 'Allcede 123' , counting more than 5? If yes, what would you like to see in the output, especially for the 6th or later.
Something like...
| Code: |
--some data
--some data
Allcede 123
Allcede 123
--some data
--some data
Allcede 123
--again some more data
Allcede 123
Allcede 123
Allcede 123
Allcede 123 |
|
|
| Back to top |
|
 |
vickey_dw
New User
Joined: 10 Jun 2015 Posts: 51 Location: India
|
|
|
|
| Quote: |
| Will your input have random occurrences of 'Allcede 123' , counting more than 5? If yes, what would you like to see in the output, especially for the 6th or later. |
No.Input file is exactly same as i have given in earlier post. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
On INREC use IFTHEN=(WHEN=(logicalexpression to identify your 'Allcede 123' and temporarily extend the records with a SEQNUM.
Then five IFTHEN=(WHEN=( to rest for the sequence number allocated being 1, 2, 3, 4, 5 with OVERLAY to make the change.
Use IFOUTLEN to return records to original size (since the extension is not needed once it has been used). |
|
| Back to top |
|
 |
vickey_dw
New User
Joined: 10 Jun 2015 Posts: 51 Location: India
|
|
|
|
Hi Bill
Thanks for the suggestion.
But i have confusion here after adding sequence number for every occurrence of "Allcede 123" .How to replace it by "Allcede 777","Allcede 666","Allcede 555","Allcede 444","Allcede 222" |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| If sequence number is one, you put the first value, if sequence number is two, you put the second, if sequence number is three, you put the third, and so on. |
|
| Back to top |
|
 |
vickey_dw
New User
Joined: 10 Jun 2015 Posts: 51 Location: India
|
|
|
|
| Thank You Bill !!! |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|