Can we append a constant number to records after an interval?

IBM's Sort Product, ICETOOL, ICEMAN and ICEGENER.
Post Reply
Biden
Registered Member
Posts: 21
Joined: Thu Jul 25, 2013 12:19 pm

Can we append a constant number to records after an interval?

Post by Biden »

Hi,

For a Fixed-block file, if I need to append two different constant number to records, at the end; can I do that? For example, if my input file has say 20K records. Can I append a constant number of two digits at the end of every 7th and 10th records. I also want to count them, is it possible? If yes, can you please help me.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Can we append a constant number to records after an interval?

Post by Robert Sample »

If yes, can you please help me.
The simplest way would be to write a program in the language of your choice to count the records and output the appropriate constants.  If your site has SAS, such a program would easily be coded, tested, and executed in half a day or less by any competent SAS programmer.
You can probably do this with the sort product in use at your site, but you need to provide more information before anyone on this (or any) forum could help you.  For example, you didn't say if you want to add 2 bytes to the record length or if there are blanks at the end of the record you want to replace with your constants.  You didn't say what happens every 70th record when the 7th and 10th records are the same -- append the 7 value? append the 10 value? append both values and add 4 bytes instead of 2 bytes?  We would also need to know which sort product your site uses.
Biden
Registered Member
Posts: 21
Joined: Thu Jul 25, 2013 12:19 pm

Re: Can we append a constant number to records after an interval?

Post by Biden »

We are using DFSORT. I would like to add 2 bytes to the record length. I did not think about 70th record while posting but appending both values, 4 bytes, will be fine.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Can we append a constant number to records after an interval?

Post by Robert Sample »

If you add 2 bytes every 7th and 10th records, and 4 bytes every 70th record, you are no longer talking about fixed-length records.
You can use IFTHEN and OUTREC in DFSORT to generate a sequence number and check for appropriate values to add your bytes.  It would be worth considering writing a short program in the language of your choice to do this, though, since getting DFSORT processing correct can take as long or longer than coding.  A SAS program for this would be less than a screen of code, based on what you've said so far.  Part of becoming an experienced programmer is learning when to use the utilities available and when to write code.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Can we append a constant number to records after an interval?

Post by William Collins »

Yes, it can be done, a little faster than Robert is alluding :-)

What do you want to put in those two bytes?

Do you want separate counts, or a count of records changed? Actually, separate counts are easy (divide total number of records by seven for the first and 10 for the second). There's even a formula to calculate how many there are "net" (only counting a seven-and-10 as one). Something to do with "triangular"? Robert will probably know much better than I.
Biden
Registered Member
Posts: 21
Joined: Thu Jul 25, 2013 12:19 pm

Re: Can we append a constant number to records after an interval?

Post by Biden »

William Collins wrote:Yes, it can be done, a little faster than Robert is alluding :-)

What do you want to put in those two bytes?

Do you want separate counts, or a count of records changed? Actually, separate counts are easy (divide total number of records by seven for the first and 10 for the second). There's even a formula to calculate how many there are "net" (only counting a seven-and-10 as one). Something to do with "triangular"? Robert will probably know much better than I.
I want to add numbers as of now.
Separate counts is fine. By 'triangular' what do you mean?
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DFSort, ICETOOL, ICEMAN, ICEGENER.”