BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Malk020
Fluorite | Level 6

Please, anyone, tell me how to use the reverse function or if there is an alternative way to reverse the Value in a numeric Variable.

 

 

  1. The survey questions were measured on a scale of 0 (least) to 3 (most).

    However, the data were recorded inconsistently by data entry clerks; and questions 2, 3, and 5 (for every visit) were accidentally recorded in the reverse order (0=most and 3=least). Convert questions 2, 3, and 5 for every visit so that they are measured in the same direction as the other questions.

 

What I did is using 


data surveyB;
set survey_1;
backward=reverse('Q3');
put backward=;
run;

proc print data = surveyB; run;

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Simple math will do this. Let's see, you want them to be 0 (least) and 3 (most), but some questions have 3 (least) and 0 (most), then for those questions something like this:

 

correct_score = -score + 3;

 

 

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Simple math will do this. Let's see, you want them to be 0 (least) and 3 (most), but some questions have 3 (least) and 0 (most), then for those questions something like this:

 

correct_score = -score + 3;

 

 

--
Paige Miller
Malk020
Fluorite | Level 6
Thank you so much.

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
  • 2 replies
  • 1744 views
  • 0 likes
  • 2 in conversation