Hi,
My questions are:
1) how to convert birth date and admission date into usable format because when I try to generate new variable using this command gen dob2 = date(Birth_Date, "DMY") it does not work and give missing values for all observations which is not true. I am assuming because the year is not spelling out completely in the original variable as seen in the example?
2) some observations under variable Surg_Date has date and time together, how to remove the time only and keep the date, also who to convert ##NULL into (0) or missing?
Thanks for helping
My questions are:
1) how to convert birth date and admission date into usable format because when I try to generate new variable using this command gen dob2 = date(Birth_Date, "DMY") it does not work and give missing values for all observations which is not true. I am assuming because the year is not spelling out completely in the original variable as seen in the example?
2) some observations under variable Surg_Date has date and time together, how to remove the time only and keep the date, also who to convert ##NULL into (0) or missing?
Code:
clear input str9(Birth_Date Admission_Date) str16 Surg_Date " 3-Jul-12" "31-Dec-20" "#NULL!" "30-Aug-15" "29-Dec-20" "#NULL!" "26-Nov-14" "29-Dec-20" "#NULL!" "26-Mar-09" "28-Dec-20" "#NULL!" "25-May-20" "31-Dec-20" "#NULL!" "29-Jan-12" " 1-Jan-21" "#NULL!" " 7-Dec-18" " 2-Jan-21" "#NULL!" "29-Jul-72" "12-Nov-20" "#NULL!" "29-Dec-20" "29-Dec-20" "#NULL!" " 6-Sep-61" "30-Dec-20" "#NULL!" "10-Aug-03" "15-Nov-20" "#NULL!" "10-Jul-42" "22-Dec-20" "#NULL!" "23-Apr-78" "30-Dec-20" "12/31/2020 12:00" "28-Dec-03" "31-Dec-20" "12/31/2020 12:00" "17-Sep-53" "30-Aug-20" "#NULL!" "25-Aug-78" " 2-Jan-21" "#NULL!" " 7-Mar-99" "30-Dec-20" "#NULL!" "29-Nov-87" "30-Dec-20" "12/30/2020 12:00" " 9-Apr-13" "29-Dec-20" "#NULL!" "28-Nov-20" " 4-Jan-21" "#NULL!" end
Thanks for helping

Comment