InPanic
InPanic

Reputation: 165

Using List-command with variable names as values

I want to use the list command in the following way:

list var1 var2 var3 if condition

var1 and var2 are normal variables and I want their values displayed with the list command. var3 however should be a variable which has the variable name of var2.

The result would be:

value_of_var1 | value_of_var2 | variable_name_var2

I know that works in SPSS but have no idea how to do that in Stata.

Upvotes: 0

Views: 389

Answers (1)

TheIceBear
TheIceBear

Reputation: 3255

I do not understand why you want this (but I am sure you have a good reason) so I am not sure this is the best solution, but you could do this:

gen var3 = "variable_name_var2"

list var1 var2 var3 if condition

It might be a bit manual but since you did not state that you will repeat this for many variables, it might work for you.

Upvotes: 2

Related Questions