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
generating separate variables from one variables's observations, is there a loop?Dear all, From the variable v I would like to generate 3 variables: v1, v2, v3. Given that these ar…
Cleaning for Optimal Modeling (ft. Panel Data)Hello Everyone, Let's say I would like to do a linear regression on some Panel data without knowing…
parsing a variable based on digitsDear All, I try to create a new variable (let's say caseid_copy) based on the original caseid. Howe…
Mean of means, with means obtained from by year, sort + weigthsHello, I have obtained the mean, median, stdev by year (I have 18 years in the sample) for my expen…
exporting many tables to excelHi , I have a question about how I can export many tables in a good format. I am trying to run regre…
Subscribe to:
Post Comments (Atom)
0 Response to Regarding inclusion of duplicates
Post a Comment