Let's say I have 5 different variables that can take values ranging from 1 to 10.
Var1 | Var2 | Var3 | Var4 | Var5 |
1 | 0 | 3 | 1 | 0 |
1 | 1 | 1 | 1 | 0 |
0 | 0 | 1 | 1 | 5 |
0 | 1 | 1 | 1 | 5 |
0 | 0 | 1 | 2 | 4 |
0 | 0 | 1 | 3 | 3 |
2 | 1 | 2 | 4 | 2 |
3 | 1 | 0 | 5 | 1 |
Based on the values of these variables I would like to create a string variable that summarises the information in the given column.
For instance: For the first row this variable will take the following value "1*Var1 + 3*Var3 + 1*Var4". For the second row it will be: "1*Var1 + 1*Var2 + 1*Var3 + 1*Var4".
You can think of these variables as drugs and corresponding numeric values as doses that each patient has taken.
Could you please help me with this.
0 Response to Creating a string variable based on values of different variables
Post a Comment