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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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