Thursday, June 30, 2022

how to replace/recode variables that are a multiple of some number

Hi I have a variable "level" that ranges from 1 to 125
I would like to recode it into a variable "pitch", such that values 1, 6, 11, 16, 21 ... etc are coded as "1" for pitch and values 2, 7, 12, 17, 22... etc ared coded as "2" for pitch
I could do that manually with recode e.g.
HTML Code:
recode level 1=1 6=1 11=1 etc, gen(obj)
but it would take a long time

Is there a quicker way to do this?

No comments:

Post a Comment