So I have a macro that is creating a list of games a person is going to see during the year. Lets say the first game they will see is game 'A'. I then have another dataset that has all the players that play in game 'A'. For each of these players, I need to mark that I have seen these players so I decrease the number of times I still need to see them.
So here is the dataset with the players:
Player | Game | Team | TImes seen | Position |
---|---|---|---|---|
12 | A | BBB | Pitcher | |
45 | A | BBB | Out fielder | |
84 | A | CCC | 3rd baseman |
So in game A, I could see all these players. But I need to choose if I see 'BBB's players or 'CCC's players, since I cant see players from opposing teams. so basically, if I see game A, I want to randomly select a player that I see, and then see all the other players on that team (so I would see player 12 and 45 if it randomly selects a player from that team, or just player 84 if it selects that player). Does this sound like it would need to be really complicated?
Right now, all I do is update times seen to be +1 if we see game A, and need to add this random and conditional element to it. How would you go about doing this?
Hello,
It is completely depands on How you randomly taking players...For Example, at first time you randomaly took player 12 and 45 then you can eassily automate the process but if at second time if you randomaly took player 84 then you have to think different logic so that you can update time seen variable...
In short, it is more on How you selects the Players...
I tried to make logic for this but i stuck on if user execute code different time, he or she will get different players each time...so...
it will be good if you post output you want and how you selects the players...
Thanks,
Urvish
I am running this multiple times, so here it what it looks like.
A game is chosen, and outputs game 'A'. Then I use sql right now to change a variable called 'viewed' to 1 for each player in that game. Then total number of views is calculated for each player, then the algorithm chooses the next game, and I updated the views, and so forth.
So the algorithm ends up with a list of lets say 100 games (in one column), and then I have to look up that list, and update the views for the players in those 100 games.
I do want to randomly select which player I see based on game A. So we see game A, I want to randomly select one player I see. Then I can write code to mark other players in that game as seen based on some criteria I have. So it might randomly select player 12, then based on my criteria it would also mark player 45. Are you saying the problem is as it adds to the list, the randomly chosen player would change each time?
Yes Xamius32, i stuck on while i came to know that Player can be change each time depands on random selection...So request you to fix the selection criteria of Players so that we can prepare the code and it will give you the desire output...
If i have player 12 then that player comes from team 'BBB' so i will add in Time Seen as follows...
Player Team Time Seen
12 BBB 1
45 BBB 2
84 CCC 0
I prepared SAS Code when player is 12...But if user execute code such a way that he/she got player 84 then the Code wont work...So the question is we need to either change logic for each randomly drawn of players or need to fix the selection criteria for team or players...
Thanks,
Urvish
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.