BookmarkSubscribeRSS Feed
yoyong
Obsidian | Level 7

Hi everyone.

 

I have twenty questions: Q1 - Q20. The responses are in the form of Likert scale.

 

1 – “strongly agree”

2 – “somewhat agree”

3 – “neither agree no disagree’

4 – “somewhat disagree’

5 – “ strongly disagree”

 

How do I do reverse coding for all questions at one time?

 

Thanks for your help.

 

3 REPLIES 3
HB
Barite | Level 11 HB
Barite | Level 11

This site:

 

https://www.theanalysisfactor.com/easy-reverse-code/

 

is suggesting a neat subtraction trick:

 

Data yourdata;
Set yourdata;
NewVariable = 6 – OldVariable;
Run; 

 

so

q1recode = 6 - q1;

 

If q1 is a 5, q1recode becomes a 1. 

If q1 is a 1, q1recode becomes a 5.

 

 

Reeza
Super User

Use arrays and math.

 

data want;
set have;

array _Q(20) Q1-Q20;

do i=1 to dim(_Q);
_q(i) = 6 - _q(i);
end;

run;
SuryaKiran
Meteorite | Level 14

Not sure what your trying to do. As far as I understood here is my tip:

 

If your scale is in continuous sequence then 

data test;
input num;
datalines;
1
2
3
4
5
;
run;

proc sql;
select *,(max(num)+1)-num as new_num
from test;
quit;

If not  continuous then, 

data test;
input num;
datalines;
1
2
4
5
;
run;
proc sort data=test out=reverse_test;
by descending num;
run;
data reverse;
merge test reverse_test(rename=(num=new_num));
run;

 

Thanks,
Suryakiran

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 6378 views
  • 3 likes
  • 4 in conversation