Hello, I have a simple problem I would apprecieate any help with.
Suppose in my dataset I have a variable called TYPE which is A, B, C, or D. Furthermore I have four additional variable xA, xB, xC, xD. What I would like to do is create a new variable x that has the appropriate xA, xB, etc value depending on the TYPE. So if TYPE=A then x=xA, etc. Here is an example table;
TYPE
xA
xB
xC
xD
x
A
1
3
0
2
1
D
0
9
5
3
3
C
4
2
0
0
0
I've tried x=x||TYPE and call execute('x=x'||TYPE||';'); but to no avail. I read that you can use some combination of symput and symget.
At worst I can do if TYPE='A' then x=XA, etc. but this is really inefficent code (I have 20 different TYPE letters).
Is there an elegant solution for this?
Thank you!
... View more