Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I need to replicate a few rows where the replicated row would have a changed value in just one dimension. I have attached a table containing some sample data:
Name | Number | Country | Start Year | End Year | AY |
ABC | A123 | France | 2003 | 2006 | 2004 |
ABC | A456 | France | 2003 | 2006 | 2004 |
ABC | France | 2003 | 2006 |
In my data, the dimension AY would have a value only if the column 'Number' has a value. What I need to do is, in cases where the accident year is blank, I need to replicate the corresponding row as many times as the effective duration which is the period between the end year and the start year. The output needs to resemble the following format:
Name | Number | Country | Start Year | End Year | AY |
ABC | A123 | France | 2003 | 2006 | 2004 |
ABC | A456 | France | 2003 | 2006 | 2004 |
ABC | France | 2003 | 2006 | ||
ABC | France | 2003 | 2006 | 2003 | |
ABC | France | 2003 | 2006 | 2004 | |
ABC | France | 2003 | 2006 | 2005 | |
ABC | France | 2003 | 2006 | 2006 |
I was wondering how I could do this in the script using loops, because I have around 30000 cases in my data where I need to do the same.
Thanks and Regards,