Hi all, I have a data set which contains information on participants that were a part of projects for multiple rounds. The variables include: ParticipantID - Participant ID, because participants are in multiple rounds, there are multiple rows for each participant. Round_Project - Indicates the round the project was in (i.e. Round_1A_Project_ID indicates Round 1 Project 1, Round_1B_Project_ID indicates Round 1 Project 2, Round_2A_Project_ID indicates Round 2 Project 1) There are a total of 4 rounds, with up to three different projects per round. Project_ID - gives the specific project ID I would like to construct a new variable (I would name it 'Team') that groups the participants based on the same ProjectID and Round. For example I would want to know the best way to construct the 'Team' variable such as this: ParticipantID Round_Project Project_ID Team 1387 Round_1A_Project_ID 2020-01-2102 1 1406 Round_1A_Project_ID 2020-01-2102 1 1387 Round_1B_Project_ID 2020-01-2133 1 1406 Round_1B_Project_ID 2020-01-2133 1 1387 Round_1C_Project_ID 2020-01-2136 1 1406 Round_1C_Project_ID 2020-01-2136 1 1387 Round_3A_Project_ID 2020-01-2310 1 1406 Round_3A_Project_ID 2020-01-2310 1 1371 Round_1A_Project_ID 2020-01-2103 2 1389 Round_1A_Project_ID 2020-01-2103 2 1371 Round_3A_Project_ID 2020-01-2311 2 1389 Round_3A_Project_ID 2020-01-2311 2 1371 Round_3B_Project_ID 2020-01-2304 2 1389 Round_3B_Project_ID 2020-01-2304 2 1385 Round_1A_Project_ID 2020-01-2104 3 1414 Round_1A_Project_ID 2020-01-2104 3 1429 Round_1A_Project_ID 2020-01-2104 3 1385 Round_2A_Project_ID 2020-01-2217 3 1414 Round_2A_Project_ID 2020-01-2217 3 1429 Round_2A_Project_ID 2020-01-2217 3 Code for the original data. data SASHELP;
input ParticipantID:32. Round_Project:$20. Project_ID:$20.;
datalines;
1387 Round_1A_Project_ID 2020-01-2102
1406 Round_1A_Project_ID 2020-01-2102
1387 Round_1B_Project_ID 2020-01-2133
1406 Round_1B_Project_ID 2020-01-2133
1387 Round_1C_Project_ID 2020-01-2136
1406 Round_1C_Project_ID 2020-01-2136
1387 Round_3A_Project_ID 2020-01-2310
1406 Round_3A_Project_ID 2020-01-2310
1371 Round_1A_Project_ID 2020-01-2103
1389 Round_1A_Project_ID 2020-01-2103
1371 Round_3A_Project_ID 2020-01-2311
1389 Round_3A_Project_ID 2020-01-2311
1371 Round_3B_Project_ID 2020-01-2304
1389 Round_3B_Project_ID 2020-01-2304
1385 Round_1A_Project_ID 2020-01-2104
1414 Round_1A_Project_ID 2020-01-2104
1429 Round_1A_Project_ID 2020-01-2104
1385 Round_2A_Project_ID 2020-01-2217
1414 Round_2A_Project_ID 2020-01-2217
1429 Round_2A_Project_ID 2020-01-2217
;;;; I was advised that it may be possible to do this with loops, but any solution is welcome. Thank you!
... View more