I have the following data matrix containing Poole dw-nominate scores:
con statenm party name dwnom1
80 USA 100 TRUMAN -.276
80 ALABAMA 100 BOYKIN F -.026
I was wondering if there was a way in Stata to turn the USA dwnom1 value into a specific variable, USA_dwnom1. I'd like to have each variable with a value of cong == 80 to have the value of -.276 for each value of the new variable of USA_dwnom1.
Once more, I was wondering if there was a way to do this in a loop (I'm doing this from the 80th to the 112th Congress).
There are many ways of doing this. Here's one using a user-written command
xfill
:carryforward
is another option. Some other first-principles solutions that usereplace
and subscripting can be found here.There's no need to loop over congresses.