Dear all,
I have a question regarding the rowsort command. I am trying to sort the values of some variables horizontally (so in a row) but each of this variables to sort has another variable that describes the variable and should therefore be sorted accordingly. Here is an example:
Imagine my data look like this:
var1 | var1_desc | var2 | var2_desc | var3 | var3_desc | etc.
2 blue 3 red 1 yellow
I would like to rowsort var1-var3 but don't lose the information in the var_desc variable, i.e. the value of var1 is only described by blue, the value of var 2 with red etc. So ideally I would like to look my data like this:
Var1 | var1_desc_sorted | Var2| var2_desc_sorted | Var3 | var3_desc_sorted
1 yellow 2 blue 3 red
When I just code:
rowsort var*, generate(var1_sorted-var3_sorted)
I get the following:
Var1 | var1_desc | Var2| var2_desc | Var3 | var3_desc
1 blue 2 red 3 yellow
The information in the var_desc variables are matched to the wrong variable. Does anyone know how to solve this?
Thank you very much for your help.
Best,
Mara
I have a question regarding the rowsort command. I am trying to sort the values of some variables horizontally (so in a row) but each of this variables to sort has another variable that describes the variable and should therefore be sorted accordingly. Here is an example:
Imagine my data look like this:
var1 | var1_desc | var2 | var2_desc | var3 | var3_desc | etc.
2 blue 3 red 1 yellow
I would like to rowsort var1-var3 but don't lose the information in the var_desc variable, i.e. the value of var1 is only described by blue, the value of var 2 with red etc. So ideally I would like to look my data like this:
Var1 | var1_desc_sorted | Var2| var2_desc_sorted | Var3 | var3_desc_sorted
1 yellow 2 blue 3 red
When I just code:
rowsort var*, generate(var1_sorted-var3_sorted)
I get the following:
Var1 | var1_desc | Var2| var2_desc | Var3 | var3_desc
1 blue 2 red 3 yellow
The information in the var_desc variables are matched to the wrong variable. Does anyone know how to solve this?
Thank you very much for your help.
Best,
Mara

Comment