Hi Friends,
I have a sample dataset as below. The actual dataset has 58 questions in stead of 10 in the example. I want to generate a new_varaible indicating any of the scale of the question larger than 8. In this example, SubjectNum 006, at VisitNum 2 has one of the question being 9, then the new_variable = "scale large than 8". How should I write the code?
Thanks.
I have a sample dataset as below. The actual dataset has 58 questions in stead of 10 in the example. I want to generate a new_varaible indicating any of the scale of the question larger than 8. In this example, SubjectNum 006, at VisitNum 2 has one of the question being 9, then the new_variable = "scale large than 8". How should I write the code?
Thanks.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str6 SubjectNum byte(VisitNum Q1 Q1a Q2 Q2a Q3 Q3a Q4 Q4a Q5 Q5a) "002" 2 1 7 1 7 1 6 1 7 1 8 "002" 3 0 1 0 1 0 1 0 1 0 1 "002" 4 1 6 1 7 0 1 1 5 1 6 "002" 5 0 1 0 1 0 1 0 1 0 1 "005" 2 1 5 1 5 1 5 0 1 1 6 "005" 99 . . . . . . . . . . "006" 2 1 8 1 9 1 8 1 9 1 9 "006" 3 1 5 1 5 1 6 1 6 1 5 "006" 4 1 6 1 6 1 7 1 9 1 8 "006" 5 1 4 0 1 0 1 0 1 0 1 end
Comment