Flip rating scale in SPSS

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Flip rating scale in SPSS

jagadishpchary
HI,

I need to flip a rating scale for one of the variable and i am using the
below code
e.g. RECODE arg4 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1).

Can anyone help with the SPSS code using loops - as i need to do it for
other rating scale variable too like 10 - 1 & 5 - 1 rating scales.

FYI - I need only one SPSS code (loops) which handles all types of rating
scales.

Thanks for the help in advance.

Regards,
Jagadish




--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Flip rating scale in SPSS

Jeanne Eidex
You can just add the additional variable names after the recode command like this...

Recode arg4 arg10 arg1 arg5 (1=7) (2=6).

I didn’t type in all of your recodes but that is how you do it, loop not necessary.

Jeanne





From: SPSSX(r) Discussion <[hidden email]> on behalf of jagadishpchary <[hidden email]>
Sent: Tuesday, April 28, 2020 7:17:24 AM
To: [hidden email] <[hidden email]>
Subject: Flip rating scale in SPSS
 
HI,

I need to flip a rating scale for one of the variable and i am using the
below code
e.g. RECODE arg4 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1).

Can anyone help with the SPSS code using loops - as i need to do it for
other rating scale variable too like 10 - 1 & 5 - 1 rating scales.

FYI - I need only one SPSS code (loops) which handles all types of rating
scales.

Thanks for the help in advance.

Regards,
Jagadish




--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Flip rating scale in SPSS

Jon Peck
In reply to this post by jagadishpchary
Jeanne gave you a good tip on combining the recodes.

Here is a way to automate this further.  It defines a reverser function based on the maximum value you specify and a variable list like this.

begin program.
import spss
def rev(maxval, varlist):
    inval = range(1, maxval+1)
    outval = range(maxval, 0, -1)
    rec = "".join(["(%s = %s)" %(inv, outv) for inv, outv in zip(inval, outval)])
    cmd = """RECODE %(varlist)s %(rec)s""" % locals()
    spss.Submit(cmd)
end program.

Then you can invoke this as follows specifying the maximum value and, in quotes, the variable list on the assumption that it starts at 1 and ends at maxval.  
You can have as many calls as desired in this program.
It generates and runs the RECODE commands

begin program.
rev(7, "a b c")
rev(10, "d to k")
end program.

On Tue, Apr 28, 2020 at 5:17 AM jagadishpchary <[hidden email]> wrote:
HI,

I need to flip a rating scale for one of the variable and i am using the
below code
e.g. RECODE arg4 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1).

Can anyone help with the SPSS code using loops - as i need to do it for
other rating scale variable too like 10 - 1 & 5 - 1 rating scales.

FYI - I need only one SPSS code (loops) which handles all types of rating
scales.

Thanks for the help in advance.

Regards,
Jagadish




--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


--
Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Flip rating scale in SPSS

John F Hall
In reply to this post by jagadishpchary
do repeat.
y=arg1 to arg5.
compute y=(8-y).
end repeat.

-----Original Message-----
From: SPSSX(r) Discussion <[hidden email]> On Behalf Of
jagadishpchary
Sent: 28 April 2020 13:17
To: [hidden email]
Subject: Flip rating scale in SPSS

HI,

I need to flip a rating scale for one of the variable and i am using the
below code e.g. RECODE arg4 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1).

Can anyone help with the SPSS code using loops - as i need to do it for
other rating scale variable too like 10 - 1 & 5 - 1 rating scales.

FYI - I need only one SPSS code (loops) which handles all types of rating
scales.

Thanks for the help in advance.

Regards,
Jagadish




--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list of
commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Flip rating scale in SPSS

Bruce Weaver
Administrator
You can extend John's example to allow for different max values for different
variables.  E.g.,

NEW FILE.
DATASET CLOSE ALL.
DATA LIST LIST / v1 v2 v3 (3F2.0).
BEGIN DATA
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
5 6 6
5 7 7
5 7 8
5 7 9
5 7 10
END DATA.

DO REPEAT old = v1 to v3 / new = r1 to r3 / max = 5 7 10 .
- COMPUTE new = max+1-old.
END REPEAT.
FORMATS r1 to r3 (F2.0).
LIST.

OUTPUT:

v1 v2 v3 r1 r2 r3
 
 1  1  1  5  7 10
 2  2  2  4  6  9
 3  3  3  3  5  8
 4  4  4  2  4  7
 5  5  5  1  3  6
 5  6  6  1  2  5
 5  7  7  1  1  4
 5  7  8  1  1  3
 5  7  9  1  1  2
 5  7 10  1  1  1
 
Number of cases read:  10    Number of cases listed:  10


John F Hall wrote
> do repeat.
> y=arg1 to arg5.
> compute y=(8-y).
> end repeat.
>
> -----Original Message-----
> From: SPSSX(r) Discussion &lt;

> SPSSX-L@.UGA

> &gt; On Behalf Of
> jagadishpchary
> Sent: 28 April 2020 13:17
> To:

> SPSSX-L@.UGA

> Subject: Flip rating scale in SPSS
>
> HI,
>
> I need to flip a rating scale for one of the variable and i am using the
> below code e.g. RECODE arg4 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1).
>
> Can anyone help with the SPSS code using loops - as i need to do it for
> other rating scale variable too like 10 - 1 & 5 - 1 rating scales.
>
> FYI - I need only one SPSS code (loops) which handles all types of rating
> scales.
>
> Thanks for the help in advance.
>
> Regards,
> Jagadish





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Flip rating scale in SPSS

Rich Ulrich
In reply to this post by John F Hall
I read the question as, How to do a bunch of recodes with several
sets of variables with different limits. So I modify Bruce's code a bit,


DO REPEAT old = v1 to v3  var 10 to var23 var44 to var50/
             new = r1 to r3   r10 to r23  r44 to r50/
             max = 3 3 3   4 4 4 4   10 10 10 10 10 10 10 .
- COMPUTE new = max+1-old.
END REPEAT.
FORMATS r1 to r3 (F2.0).

COMMENT  the recoded max-values are listed under their respective sets.

--
Rich Ulrich


From: SPSSX(r) Discussion <[hidden email]> on behalf of Joihn F Hall <[hidden email]>
Sent: Tuesday, April 28, 2020 9:54 AM
To: [hidden email] <[hidden email]>
Subject: Re: Flip rating scale in SPSS
 
do repeat.
y=arg1 to arg5.
compute y=(8-y).
end repeat.

-----Original Message-----
From: SPSSX(r) Discussion <[hidden email]> On Behalf Of
jagadishpchary
Sent: 28 April 2020 13:17
To: [hidden email]
Subject: Flip rating scale in SPSS

HI,

I need to flip a rating scale for one of the variable and i am using the
below code e.g. RECODE arg4 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1).

Can anyone help with the SPSS code using loops - as i need to do it for
other rating scale variable too like 10 - 1 & 5 - 1 rating scales.

FYI - I need only one SPSS code (loops) which handles all types of rating
scales.

Thanks for the help in advance.

Regards,
Jagadish




--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list of
commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Flip rating scale in SPSS

Art Kendall
In reply to this post by jagadishpchary
you can name many variables on the command.

However, because we human beings are fallible, you might need to go back and
do it the way you intended. Good practice is to either be sure to save a new
dataset or to use INTO on the RECODE.




-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Flip rating scale in SPSS

Rich Ulrich
Art says, "Good practice is to either be sure to save a new
dataset or to use INTO on the RECODE."

YES!  especially, "use INTO on the RECODE" or otherwise
create a new variable-name.  Having a new dataset does not
prevent someone later (even, yourself, a year or more later)
from re-running your "old" syntax on the new dataset, maybe
to make use of some of the other coding or scoring, and thereby
incidentally re-reversing the scores. With potentially bad consequences.

Unless, maybe, if this is throw-away code that won't be saved
for any future at all. Even then, it must be regarded as a bad habit.

--
Rich Ulrich


From: SPSSX(r) Discussion <[hidden email]> on behalf of Art Kendall <[hidden email]>
Sent: Tuesday, April 28, 2020 11:03 AM
To: [hidden email] <[hidden email]>
Subject: Re: Flip rating scale in SPSS
 
you can name many variables on the command.

However, because we human beings are fallible, you might need to go back and
do it the way you intended. Good practice is to either be sure to save a new
dataset or to use INTO on the RECODE.




-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Flip rating scale in SPSS

Jon Peck
In reply to this post by Jon Peck
The numerical reverse (8-x) is simple, but it messes up user  missing values such as NA that might be defined.  That's why I didn't use it in my code.

On Tue, Apr 28, 2020 at 7:38 AM Jon Peck <[hidden email]> wrote:
Jeanne gave you a good tip on combining the recodes.

Here is a way to automate this further.  It defines a reverser function based on the maximum value you specify and a variable list like this.

begin program.
import spss
def rev(maxval, varlist):
    inval = range(1, maxval+1)
    outval = range(maxval, 0, -1)
    rec = "".join(["(%s = %s)" %(inv, outv) for inv, outv in zip(inval, outval)])
    cmd = """RECODE %(varlist)s %(rec)s""" % locals()
    spss.Submit(cmd)
end program.

Then you can invoke this as follows specifying the maximum value and, in quotes, the variable list on the assumption that it starts at 1 and ends at maxval.  
You can have as many calls as desired in this program.
It generates and runs the RECODE commands

begin program.
rev(7, "a b c")
rev(10, "d to k")
end program.

On Tue, Apr 28, 2020 at 5:17 AM jagadishpchary <[hidden email]> wrote:
HI,

I need to flip a rating scale for one of the variable and i am using the
below code
e.g. RECODE arg4 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1).

Can anyone help with the SPSS code using loops - as i need to do it for
other rating scale variable too like 10 - 1 & 5 - 1 rating scales.

FYI - I need only one SPSS code (loops) which handles all types of rating
scales.

Thanks for the help in advance.

Regards,
Jagadish




--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


--
Jon K Peck
[hidden email]



--
Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Flip rating scale in SPSS

Art Kendall
In reply to this post by Art Kendall
oops!  I forgot to mention ELSE=COPY  to deal with missing values.



-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Flip rating scale in SPSS

Bruce Weaver
Administrator
In reply to this post by Rich Ulrich
Another modification one could make is to allow for variables with different
minimum values (e.g., 0 to 4 rather than 1 to 5; 0 to 6 rather than 1 to 7;
-3 to +3 for a 7-point item, etc.)  

NEW FILE.
DATASET CLOSE ALL.
DATA LIST LIST / a1 to a3   b1 b2   c1 c2   d1 to d3   e1 e2   f1 f2
(14F2.0).
BEGIN DATA
 1  1  1  0  0  1  1  0  0  0  1  1  0  9
 2  2  2  1  1  2  2  1 99  1  2  2  1  8
 3  3  3  2  2  3  3  2  2  2 99  3  2  7
 4  4  4 99  3  4  4  3  3  3  4  4  3  6
 5  5  5  4  4  5  5  4  4  4  5  5  4 99
99  1  1  0  0  6  6  5  5  5  6  6  5  4
 2  2  2  1  1 99  7  6  6  6  7  7  6  3
 3  3  3  2  2  1  1 99  0  0  8  8  7  2
 4  4  4  3  3  2  2  1  1  1  9  9  8  1
 5  5  5  4  4  3  3  2  2  2 10 99  9  0
END DATA.

MISSING VALUES ALL (99).

* Change d3 from 0 to 6 TO -3 to +3.
COMPUTE d3 = d3 - 3.

DO REPEAT
  old = a1 to a3     b1  b2    c1 c2    d1 to d3    e1 e2    f1 f2 /
  new = ra1 to ra3  rb1 rb2   rc1 rc2  rd1 to rd3  re1 re2  rf1 rf2 /
  min  = 1 1 1  0 0  1 1  0 0 -3    1  1    0 0 /
  max = 5 5 5  4 4  7 7  6 6  3   10 10   9 9 .
- COMPUTE new = max+min-old.
END REPEAT.
FORMATS ra1 to rf2 (F2.0).
LIST a1 to f2.
LIST ra1 to rf2.

Notice that max+1-old has become max+min-old in this version.  

I also included some missing values in the original variables (coded as 99),
because Art mentioned missing values.  They end up being SYSMIS in the new
reversed variables.  If that is not acceptable, one could add a few more
lines of code to get 99s in the new variables to match those in the original
variables.  



Rich Ulrich wrote

> I read the question as, How to do a bunch of recodes with several
> sets of variables with different limits. So I modify Bruce's code a bit,
>
>
> DO REPEAT old = v1 to v3  var 10 to var23 var44 to var50/
>              new = r1 to r3   r10 to r23  r44 to r50/
>              max = 3 3 3   4 4 4 4   10 10 10 10 10 10 10 .
> - COMPUTE new = max+1-old.
> END REPEAT.
> FORMATS r1 to r3 (F2.0).
>
> COMMENT  the recoded max-values are listed under their respective sets.
>
> --
> Rich Ulrich





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).