I have been working on generating a new variable where 1 group would be divided into 2 subtypes and have tried several iterations, but code is not generating correct #s.
I have 1 variable with presence or absence of movements or sounds: MS where MS==0 means not present and MS==1 means present.
I also have 2 separate variables for severity of the movements or sounds: m_only (range 0-25) and s_only (range 0-25)
I want to create a new variable with individuals with MS only==1 and divide the group into categories based on their severity scores. 1= individuals with MS with motor only scores and 2= MS with vocal only scores and 3=MS individuals that answered both motor and vocal severity categories.
motor
generate m_New=.
replace m_New=1 if m_only==0 | m_only>=1.
replace m_New=. if m_only==.
(I had tried replace m_onlyN=1 if m_only>=0 and #s were not correct. above code generated correct total N for motor category)
sounds
generate s_New=.
replace s_New=1 if s_only==0 | s_only>=1
replace s_New=. if s_only==.
A few of the codes I have tried
#1
generate MS_new=.
replace MS_new=1 if MS==1 & m_NEW==1
replace MS_new=2 if MS==1 & s_NEW==1
replace MS_new=3 if MS==1 & m_NEW==1 & s_NEW==1
#2
generate MS_new=.
replace MS_new=1 if MS==1 & m_NEW==1 & m_NEW!=. & s_NEW!=1
replace MS_new=2 if MS==1 & s_NEW==1 & s_NEW!=. & m_NEW!=1
replace MS_new=3 if MS==1 & m_NEW==1 & s_NEW==1
#3 tried to generate new category without the MS category
generate m_vs_s=.
replace m_vs_s=1 if m_only>=0
replace m_v_s=2 if s_only>=0
I have tried different iterations and code not generating what I am hoping to do. I appreciate anyone's help/suggestions.
I have 1 variable with presence or absence of movements or sounds: MS where MS==0 means not present and MS==1 means present.
I also have 2 separate variables for severity of the movements or sounds: m_only (range 0-25) and s_only (range 0-25)
I want to create a new variable with individuals with MS only==1 and divide the group into categories based on their severity scores. 1= individuals with MS with motor only scores and 2= MS with vocal only scores and 3=MS individuals that answered both motor and vocal severity categories.
motor
generate m_New=.
replace m_New=1 if m_only==0 | m_only>=1.
replace m_New=. if m_only==.
(I had tried replace m_onlyN=1 if m_only>=0 and #s were not correct. above code generated correct total N for motor category)
sounds
generate s_New=.
replace s_New=1 if s_only==0 | s_only>=1
replace s_New=. if s_only==.
A few of the codes I have tried
#1
generate MS_new=.
replace MS_new=1 if MS==1 & m_NEW==1
replace MS_new=2 if MS==1 & s_NEW==1
replace MS_new=3 if MS==1 & m_NEW==1 & s_NEW==1
#2
generate MS_new=.
replace MS_new=1 if MS==1 & m_NEW==1 & m_NEW!=. & s_NEW!=1
replace MS_new=2 if MS==1 & s_NEW==1 & s_NEW!=. & m_NEW!=1
replace MS_new=3 if MS==1 & m_NEW==1 & s_NEW==1
#3 tried to generate new category without the MS category
generate m_vs_s=.
replace m_vs_s=1 if m_only>=0
replace m_v_s=2 if s_only>=0
I have tried different iterations and code not generating what I am hoping to do. I appreciate anyone's help/suggestions.
Comment