I have a data set with 3 variables: one identifies the contract number; one identifies the type of contract (two values (prime or sub); and one lists which agency let the contract. The authorizing agency is only listed for the prime contracts. I need to assign the sub contracts the same agency value as its prime.

For Example...
Contract Number Contract Type Agency
121212 Prime XX
121212 Sub
121212 Sub
343434 Prime SS
343434 Sub
343434 Sub
565656 Prime ZZ
565656 Sub
565656 Sub
what Stata code can I use so that the Sub get the Agency value of its Prime. I have 2,147 contracts with 435 primes; 1,712 subs; and 25 agencies

Thanks!

Steven Pitts