I have 2 data sets. One is called Def_Total, the other called PlayerIDs. In the PlayerIDs data set is a variable called "Bats" which corresponds to the player in question, denoted by the variable "PlayerID".
In the Def_Total data set, there is a variable called "BatterID". This corresponds to the player (variable "PlayerID") in the PlayerIDs dataset. I want to create a new variable in the Def_Total data set which corresponds to the "Bats" variable from PlayerIDs.
So it looks like this:
Take the "BatterID", match it to "PlayerID", then have the new variable, "BatterHand" = "Bats" from the PlayerIDs data set.
Now, the following code isn't correct, but gives the gist of the idea:
proc sort data=def_total;
data PlayerIDs Def_total;
do BatterID = 1 to 10234;
if BatterID = PlayerID then
BatterHand = Bats;
but the other thing is that this would take forever. It would sort through every PlayerID when setting the variable.
So 2 questions:
1.) Is there a better way to point to the PlayerID to set "BatterHand"?
2.) What's the correct syntax of the data step to make this work?
if in_PlayerIDs and in_Def_Total then output;