Page 1 of 1

To spilt the year to Months

Posted: Fri Nov 30, 2007 6:41 am
by ysrini9
Hi All,

Could any body help me how to takecare To spilt the year to Months in Datastage
--------------------------------------------------
Year Rate
---------------------------------------------------
Input : 012007 2

052007 3

012008 5

Output shoudbe:

Output: 012007 2
022007 2
032007 2
042007 2
052007 3
062007 3
072007 3
082007 3
092007 3
102007 3
112007 3
122007 3
012008 5
022008 5

please suggest me the way to achieve..Please provide me either rotinue or stored procedure or any possible way to handle in DataStage itself.

Thanks in Advance
srini

Posted: Fri Nov 30, 2007 7:35 am
by Kirtikumar
If I understand correctly what you want to do is - generate the missing months in the coming data with the no. that was assoicate with prev month in the input data.

I am not sure if u can do it in a job as there is no utility to generate rows in DS. But yes, you can do it in basic routines and write this to a file and then read that file wherever needed.

In routine, you would have to generate the months between the two incoming values and write to seq file.

Posted: Fri Nov 30, 2007 7:52 am
by chulett
Of course you can 'generate rows', all that needs is multiple output links from a transformer. That or you simply source from a transformer with the appropriate constraint.

Your requirement isn't exactly clearly stated. However, it seems like Kirtikumar might have it right. If I was doing this, I'd probably put the existing data up in a hashed file, source from a transformer generating the sequence of month/year values and pick up the rate changes from the hashed file. One problem would be when to stop, that isn't clear from your description.

Posted: Fri Nov 30, 2007 1:46 pm
by ray.wurlod
Try writing out a clear specification. By doing so you may even solve it yourself! If you do, please post your solution, so as to aid future searchers.

I think simple If statement will do

Posted: Sun Dec 02, 2007 1:32 am
by sribuz
compare the second character in year
012007 take 1 assign as a
052007 take 5 assign as b

if a<=b
then incerase a by 1
and write year as 0a2007
(this gives your result as 012007,022007,032007,042007)
and rate = prev rate (=2 in first case)
else
rate=newrate (= 5 rate of 052007)
end