Hello, i want to generate a new variable called "td" that takes on the value of the variable target if rank is 1 when dup is 1 and the value of the variable target if rank is 2 when dup is 2. the first table is the data that i have right now and the second table is the data that i want to have with the new variable. please let me know what i can do!
| Company_id | target | rank | dup |
| 1 | . | . | 1 |
| 1 | . | . | 1 |
| 1 | 3 | 1 | 1 |
| 1 | . | . | 1 |
| 1 | 5 | 2 | 1 |
| 1 | . | . | 1 |
| 1 | 7 | 3 | 1 |
| 1 | . | . | 2 |
| 1 | . | . | 2 |
| 1 | 3 | 1 | 2 |
| 1 | . | . | 2 |
| 1 | 5 | 2 | 2 |
| 1 | . | . | 2 |
| 1 | 7 | 3 | 2 |
| 1 | . | . | 3 |
| 1 | . | . | 3 |
| 1 | 3 | 1 | 3 |
| 1 | . | . | 3 |
| 1 | 5 | 2 | 3 |
| 1 | . | . | 3 |
| 1 | 7 | 3 | 3 |
| Company_id | target | rank | dup. | td. |
| 1 | . | . | 1 | 3 |
| 1 | . | . | 1 | 3 |
| 1 | 3 | 1 | 1 | 3 |
| 1 | . | . | 1 | 3 |
| 1 | 5 | 2 | 1 | 3 |
| 1 | . | . | 1 | 3 |
| 1 | 7 | 3 | 1 | 3 |
| 1 | . | . | 2 | 5 |
| 1 | . | . | 2 | 5 |
| 1 | 3 | 1 | 2 | 5 |
| 1 | . | . | 2 | 5 |
| 1 | 5 | 2 | 2 | 5 |
| 1 | . | . | 2 | 5 |
| 1 | 7 | 3 | 2 | 5 |
| 1 | . | . | 3 | 7 |
| 1 | . | . | 3 | 7 |
| 1 | 3 | 1 | 3 | 7 |
| 1 | . | . | 3 | 7 |
| 1 | 5 | 2 | 3 | 7 |
| 1 | . | . | 3 | 7 |
| 1 | 7 | 3 | 3 | 7 |

Comment