I have a dataset with the variables, bvdidnumber (companynumber), uniquecontactidentifier (employeenumber) and appointment date.
Below an example of dataset
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str16 bvdidnumber str10(dmbruciuniquecontactidentifier dmbrappointmentdate) "GB09578657" "P000376722" "" "GB09578657" "P000376722" "07/05/2015" "GB08314433" "P000716288" "30/11/2012" "GB09033844" "P001120297" "12/05/2014" "GB10190501" "P001557911" "20/05/2016" "GB10190501" "P001557911" "" "GB09339661" "P001771286" "03/12/2014" "GB10021928" "P001877355" "" "GB10021928" "P001877355" "25/02/2016" "GB10021928" "P001938743" "23/02/2016" end
I want to create a new dummyvariable called "allapointmentdatesavailableuci", which says a 0 when there is at least employeenumber without an appointmentdate per companyid, otherwise a 1.
Unfortunately, I also have some duplicate people, who for one observation have an appointment date and for another it's empty.
If this is the case I would like the new variable to account for this and not write down a 0, because I do have an appointmendate available for this employee in this company.
I tried using the following code
Code:
bys dmbruciuniquecontactidentifier bvdidnumber : gen missnappointmentdate= !missing( dmbrappointmentdate ) . bys dmbruciuniquecontactidentifier bvdidnumber : egen allappointmentdate = min (missnappointmentdate)
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str16 bvdidnumber str10(dmbruciuniquecontactidentifier dmbrappointmentdate) float allappointmentdateuci "GB09578657" "P000376722" "" 0 "GB09578657" "P000376722" "07/05/2015" 0 "GB08314433" "P000716288" "30/11/2012" 1 "GB09033844" "P001120297" "12/05/2014" 1 "GB10190501" "P001557911" "20/05/2016" 0 "GB10190501" "P001557911" "" 0 "GB09339661" "P001771286" "03/12/2014" 1 "GB10021928" "P001877355" "" 0 "GB10021928" "P001877355" "25/02/2016" 0 "GB10021928" "P001938743" "23/02/2016" 0 end
Do I need to do an extra step or create an extra dummy variable?
Thanks in advance for your help and time!
Best regards,
Laura Hill
0 Response to If observations matches on two variables, but at least one has a value for a third variable, create a new variable with output 1
Post a Comment