Hi Everyone,
I have a dataset that looks roughly like this:
input str8 month_year studyid edvisits
"AUG_08" 1 0
"SEP_08" 1 2
"OCT_08" 1 1
"NOV_08" 1 0
"DEC_08" 1 0
"AUG_08" 2 0
"SEP_08" 2 0
"OCT_08" 2 1
"NOV_08" 2 0
"DEC_08" 2 0
"AUG_08" 3 1
"SEP_08" 3 0
"OCT_08" 3 2
"NOV_08" 3 0
"DEC_08" 3 0
"AUG_08" 4 1
"SEP_08" 4 0
"OCT_08" 4 0
"NOV_08" 4 1
"DEC_08" 4 1
What I need to do is generate a new variable called "repeat_user" that =1 if a person has 3 or more edvisits in a 3 month period and =0 if they don't.
so the "want" dataset would look like this:
input str8 month_year studyid edvisits repeat_user
'AUG_08' 1 0 1
'SEP_08' 1 2 1
'OCT_08' 1 1 1
'NOV_08' 1 0 1
'DEC_08' 1 0 1
'AUG_08' 2 0 0
'SEP_08' 2 0 0
'OCT_08' 2 1 0
'NOV_08' 2 0 0
'DEC_08' 2 0 0
'AUG_08' 3 1 1
'SEP_08' 3 0 1
'OCT_08' 3 2 1
'NOV_08' 3 0 1
'DEC_08' 3 0 1
'AUG_08' 4 1 0
'SEP_08' 4 0 0
'OCT_08' 4 0 0
'NOV_08' 4 1 0
'DEC_08' 4 1 0
For patient 1 repeat_user = 1 because they has 3 visits in 2 months
For patient 2 repeat_user = 0 because they only had 1 visit
For patient 3 repeat_user = 1 because they had 3 visits in 3 months
For patient 4 repeat_user = 0 because even though they had 3 visits, they were not within a three month period
Month_year is currently formatted as a proper date variable.
Any help would be much appreciated!
Thanks so much.
Mike
I have a dataset that looks roughly like this:
input str8 month_year studyid edvisits
"AUG_08" 1 0
"SEP_08" 1 2
"OCT_08" 1 1
"NOV_08" 1 0
"DEC_08" 1 0
"AUG_08" 2 0
"SEP_08" 2 0
"OCT_08" 2 1
"NOV_08" 2 0
"DEC_08" 2 0
"AUG_08" 3 1
"SEP_08" 3 0
"OCT_08" 3 2
"NOV_08" 3 0
"DEC_08" 3 0
"AUG_08" 4 1
"SEP_08" 4 0
"OCT_08" 4 0
"NOV_08" 4 1
"DEC_08" 4 1
What I need to do is generate a new variable called "repeat_user" that =1 if a person has 3 or more edvisits in a 3 month period and =0 if they don't.
so the "want" dataset would look like this:
input str8 month_year studyid edvisits repeat_user
'AUG_08' 1 0 1
'SEP_08' 1 2 1
'OCT_08' 1 1 1
'NOV_08' 1 0 1
'DEC_08' 1 0 1
'AUG_08' 2 0 0
'SEP_08' 2 0 0
'OCT_08' 2 1 0
'NOV_08' 2 0 0
'DEC_08' 2 0 0
'AUG_08' 3 1 1
'SEP_08' 3 0 1
'OCT_08' 3 2 1
'NOV_08' 3 0 1
'DEC_08' 3 0 1
'AUG_08' 4 1 0
'SEP_08' 4 0 0
'OCT_08' 4 0 0
'NOV_08' 4 1 0
'DEC_08' 4 1 0
For patient 1 repeat_user = 1 because they has 3 visits in 2 months
For patient 2 repeat_user = 0 because they only had 1 visit
For patient 3 repeat_user = 1 because they had 3 visits in 3 months
For patient 4 repeat_user = 0 because even though they had 3 visits, they were not within a three month period
Month_year is currently formatted as a proper date variable.
Any help would be much appreciated!
Thanks so much.
Mike
Comment