View previous topic :: View next topic
|
Author |
Message |
amenon308
New User
Joined: 13 Apr 2022 Posts: 4 Location: Hyderabad
|
|
|
|
Below are record and data,
INPUT
-------------------------------------------------------------
123.23 123.54
99999.77 123.00
DESIRED OUTPUT
------------------------------------------------------------
12323 12354
9999977 12300
Tried below sort card,
OPTION=COPY
INREC FINDREP=(STARTPOS=,ENDPOS=,C'.', C'')
CHALLENGE
--------------
Once .dot operator is removed, its left shifting the data. Desired O/p is decimal point removed with values at exact same position(not left shifting). Please suggest an appropriate sort card for the same.
Note: Values are stores in Alphanumeric fields, hence is left justified. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2120 Location: USA
|
|
|
|
Code: |
FINDREP=(INOUT=(C'.',C'')) |
This is the very first explicit example of FINDREP parameter in any SORT manual |
|
Back to top |
|
|
amenon308
New User
Joined: 13 Apr 2022 Posts: 4 Location: Hyderabad
|
|
|
|
Tried this as already mentioned in my post. Problem is, it is shifting the data to the left after the dot C'.' is replaced with C''.
Do we have option to remove the dot and not shift the data to the left, to maintain the position of fields as is ? This is the main query.
Thanks |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
You can replace the period with a space. If this is unacceptable, then you need to learn to live with the fact that the data after the period will be shifted to replace the period. If this causes you problems, you need to write a program in the language of your choice to remove the period on a field by field basis. |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1202 Location: Dublin, Ireland
|
|
|
|
Your desired output shows the data left-shifted and your control card seems to show the replacement as a null (no space between quotes).
Use the code tags to show sample data.
Garry. |
|
Back to top |
|
|
amenon308
New User
Joined: 13 Apr 2022 Posts: 4 Location: Hyderabad
|
|
|
|
Input Record
Code: |
-------------------------------------------------------------
123.23 123.54
999.77 123.00 |
Desired O/p
Code: |
-----------------------------------------------------
12323 12354
99977 12300 |
Current O/p
Code: |
-----------------------------------------------------
12323 12354
99977 12300 |
My control card is not generating desired output. How to add spaces to each field as replacement for the dot(.) so that data remains in right position after sort ? |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1308 Location: Bamberg, Germany
|
|
|
|
Try SHIFT=NO and/or STARTPOS/ENDPOS parameters. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2120 Location: USA
|
|
|
|
If your field positions are fixed, then you can try:
Code: |
BUILD=(1,5,SFF,EDIT=(TTTTT),3X,
9,5,SFF,EDIT=(TTTTT),3X,
. . . . ) |
If your positions are floating, extra PARSE may be required... |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2120 Location: USA
|
|
|
|
Update: in your example the original fields are 6 characters in length:
Code: |
BUILD=(1,6,SFF,EDIT=(TTTTT),3X,
9,6,SFF,EDIT=(TTTTT),3X,
. . . . ) |
|
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1308 Location: Bamberg, Germany
|
|
|
|
For floating points, this snippet could help.
Code: |
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
BUILD=(1,8,SQZ=(SHIFT=LEFT,PREBLANK=C'.'),
9,8,SQZ=(SHIFT=LEFT,PREBLANK=C'.')))
END |
|
|
Back to top |
|
|
amenon308
New User
Joined: 13 Apr 2022 Posts: 4 Location: Hyderabad
|
|
|
|
Thanks Joerg.Findeisen. It worked. Given the right output. Thank you all for contributing . |
|
Back to top |
|
|
|