**Question:**

Suppose two companies A and B are connected in some years. Say, right now the data structure is the following:

Company 1 Company 2 Starting Year Ending Year

A B 2000 2006

A C 1998 2003

C D 1995 1997

I want to find a way to generate:

Company 1 Company 2 Year

A B 2000

A B 2001

…………….

A B 2006

A C 1998

……………..

A C 2003

C D 1995

……………..

C D 1997

**Answer:**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
DATA temp01; INPUT id1 id2 year1 year2; DATALINES; 100 501 1999 2003 200 688 2007 2011 333 777 1995 2008; run; data temp02; set temp01; do i= 0 to (year2-year1); year=year1+i; output; end; keep id1 id2 year; run; |