BookmarkSubscribeRSS Feed
Xamius32
Calcite | Level 5

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:

PlayerGameTeamTImes seenPosition
12ABBBPitcher
45ABBBOut fielder
84ACCC3rd 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?

3 REPLIES 3
UrvishShah
Fluorite | Level 6

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


Xamius32
Calcite | Level 5

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?

UrvishShah
Fluorite | Level 6

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 745 views
  • 0 likes
  • 2 in conversation