Hello snair1981.
Could you please clarify the problem?
Because what you described don't match with the sample data.
> data ttt;
> infile cards truncover;
> input year id $ id1 $;
> cards;
> 1999 8888
> 2000 66789 96876
> 2003 93693 42541
> 1996 78965 78545
> 2002 42541
> 2000 7796 8888
> 2001 42541 7796
> 2005 7798
> 2005 7798 1245
> 2004 4472 6668
> 2005 63373 737373
> ;
First, the above code will not produce the data bellow (imissing some rows).
> This is the sample data
> Year id id1
> 1999 8888
> 2000 66789 96876
> 2003 93693 42541
> 2003 65574 64647
> 1996 78965 78545
> 2004 64647 63373
> 2002 42541
> 2000 7796 8888
> 2001 42541 7796
> 2005 7798
> 2005 7798 1245
> 2004 4472 6668
> 2005 63373 737373
Then...
> Final Output
>
> Year id id1 idnew
>
> 2003 93693 42541 93693
> 2002 42541 93693
> 2001 42541 7796 93693
> 2000 7796 8888 93693
> 1999 8888 93693
OK for the above group, but...
> 2005 737373 63373 737373
> 2004 63373 64647 737373
> 2003 64647 65574 737373
Here id's are swapped from original sample...
So...
Should the data be paired then pairs should be swapped and paired again?!?
Could you please be more specific about your task?
Cheers from Portugal.
Daniel Santos @
www.cgd.pt.