Hello,
I have data wherein patients have multiple assessment types. I would like to create a new variable that numbers (1,2,3 etc) for the subgroup of Assessment.
I've tried the bysort command that i've seen in previous posts: bysort Assessment id: gen newvar=(_n)
but this does not give me the desired outcome.
This is what I'm trying to achieve:
id. assessment. newvar
1. SOC 1
1. dischargetype1. 2
1 dischargetype2. 3
2. SOC 1
2. dischargetype3. 2
3. dischargetype1. 1
3. SOC 2
3. dischargetype2. 3
4. SOC 1
Thank you!
I have data wherein patients have multiple assessment types. I would like to create a new variable that numbers (1,2,3 etc) for the subgroup of Assessment.
I've tried the bysort command that i've seen in previous posts: bysort Assessment id: gen newvar=(_n)
but this does not give me the desired outcome.
This is what I'm trying to achieve:
id. assessment. newvar
1. SOC 1
1. dischargetype1. 2
1 dischargetype2. 3
2. SOC 1
2. dischargetype3. 2
3. dischargetype1. 1
3. SOC 2
3. dischargetype2. 3
4. SOC 1
Thank you!
Comment