[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: [reversing a variable]
This problem is easy to describe but fiddly to
. replace myvar = 5 - myvar
fixes the values, but almost certainly you have
value labels to switch as well.
There is a canned solution in -vreverse- on SSC.
. ssc inst vreverse
. help vreverse
> I am new to Stata and am trying to work out the solution to something
> that probably has a simple solution.
> I have data in a variable coded something along the lines of 1(very
> happy), 2(happy), 3(not so happy) and 4(miserable). All I want to do
> is switch this around so that 1 becomes 4, 2 becomes 3 and so on. I
> realise that I could use recode but was wondering if there is a
> remarkably simple solution that I cannot find.
* For searches and help try: