Hey guys...
My name is Felix, and I'm new here to this forum...
Actually, statalist.org has helped me a lot within the course of the last year, but now I face a problem I can't find any answers for.
So any kind of help would be highly appreciated.
I have a panel dataset on hand, basically in the form of the table shown below...
(The table only shows 1 ID. Naturaly, it should apply to all IDs in the end.)
The table shows the initial situation (first 6 columns) and the intended solution (last 2 columns).
So what I want to do is rather simple...(maybe even the answer to the problem is obvious and it's just me who is really puzzled...
)
I want to multiply the value in column "Quan" with one of the values from the columns "FR01" or "AT07", just depending on whether column "BS" contains the respective variable name as string, and want to put the result in a new variable, again distinguishing between the variables, respectively.
So the main question is, how can I "read" the content of the string variable "BS" and tell Stata that this is actually the name of an existing variable?
(Maybe it's important to note that this is only a very condensed version...my datafile will contain about 700 different variables like "FR01" or "AT07", referring to different stocks)
Looking forward to your support!
Thanks in advance,
Best wishes,
Felix
My name is Felix, and I'm new here to this forum...
Actually, statalist.org has helped me a lot within the course of the last year, but now I face a problem I can't find any answers for.
So any kind of help would be highly appreciated.
I have a panel dataset on hand, basically in the form of the table shown below...
(The table only shows 1 ID. Naturaly, it should apply to all IDs in the end.)
The table shows the initial situation (first 6 columns) and the intended solution (last 2 columns).
So what I want to do is rather simple...(maybe even the answer to the problem is obvious and it's just me who is really puzzled...

I want to multiply the value in column "Quan" with one of the values from the columns "FR01" or "AT07", just depending on whether column "BS" contains the respective variable name as string, and want to put the result in a new variable, again distinguishing between the variables, respectively.
So the main question is, how can I "read" the content of the string variable "BS" and tell Stata that this is actually the name of an existing variable?
(Maybe it's important to note that this is only a very condensed version...my datafile will contain about 700 different variables like "FR01" or "AT07", referring to different stocks)
Looking forward to your support!
Thanks in advance,
Best wishes,
Felix
ID | Date | BS | Quan | FR01 | AT07 | V(FR01) | V(AT07) |
1 | 07/08/2005 | FR01 | 15.0 | 22.05 | 7.25 | 330.75 | . |
1 | 07/09/2005 | . | . | 22.50 | 7.15 | . | . |
1 | 07/10/2005 | AT07 | 15.0 | 23.50 | 7.00 | . | 105.00 |
1 | 07/11/2005 | FR01 | -7.0 | 22.85 | 7.55 | -159.95 | |
1 | 07/12/2005 | . | . | 24.05 | 7.90 | . | . |
1 | 07/13/2005 | AT07 | -10.0 | 25.00 | 8.10 | . | -81.0 |
Comment