Hi, I am having problem in generating a new variable. So, I want to generate a variable from a date variable which has duplicate dates but their case id are different and I need all numbers.
I tried with the commands mentioned below:
1) gen cv_date_twelve=.
replace cv_date_twelve=1 if cv_date3 !=. | cv_date6 !=. | cv_date9 !=. | cv_date12 !=.
replace cv_date_twelve=0 if cv_date_twelve==.
tab cv_date_twelve
2)gen cv_date_twelve=.
replace cv_date_twelve=cv_date3 if cv_date3 !=.
replace cv_date_twelve=cv_date6 if cv_date6 !=.
replace cv_date_twelve=cv_date9 if cv_date9 !=.
replace cv_date_twelve=cv_date12 if cv_date12 !=.
replace cv_date_twelve=0 if cv_date_twelve==.
tab cv_date_twelve
Kindly help.
Regards,
Harpreet
Related Posts with Regarding inclusion of duplicates
Calculating proportions of the make-up of different program groups at different measurement occasions - helpHello, My dataset consists of ~6000 referrals to a suite of four types of psychological programs ov…
Integer related issueI'm new to STATA. I used Excel prior but recently purchased STATA. I'm learning as I go. Here is my …
Choice model (cm) data layoutHi all, I am in the midst of setting up my data to run a panel-data mixed logit choice model (cmxtm…
Graphing two categorical variablesHello everyone, I'm new to the Forum and relatively beginner at Stata, so sorry if the answer for w…
Is it valid to apply fixed effects or GMM method to this model?The model is attached. This model is special as it includes macro environment variables (FB and X) w…
Subscribe to:
Post Comments (Atom)
0 Response to Regarding inclusion of duplicates
Post a Comment