Hi everybody,
My database contains is of the form:
DATE--------ID------RETURN MKTRETURN RISKFREE
02jan1986-12222 0.02------- 0.011-------------0.001
I furthermore have a list of dates in an Excel file of the form:
LIST1 ------LIST2 LIST3 LIST1+LIST2 LIST2+LIST3 LIST1+LIST3 LIST1+LIST2+LIST3
03jul1987 09sep1943....
I would like to create a dummy variable in the return dataset for every list of dates that is 1 when the corresponding date is equal to one of the dates in one list. For example: if 02jan1986 is a date contained in list1 but not in the other lists, the first dummy variable dummy variable should be 1 and all the other variables should be zero for that return and that date.
My solution would be to create a esparated dta file for every list, create a dummy variable which is always equalt to one, rename the list of date as "DATE" and merge the return database (the first one) with this new database for every list of dates, so that at the end I would have 1 for the dates that match and a missing value otherwise, so that the dummy variable I desire would be basically done. However, in trying to do this,
merge m:1 DATE using Listofdate1.dta
I got the error: variable DATE does not uniquely identify observations in the using data. The every list of dates has unique values, except for the last four lists, which are combinations of the former original lists. However, I get this error even if I use a list with unique values. DATE is not unique in the database I start with.
Hope someone can help
Thank you in advance
My database contains is of the form:
DATE--------ID------RETURN MKTRETURN RISKFREE
02jan1986-12222 0.02------- 0.011-------------0.001
I furthermore have a list of dates in an Excel file of the form:
LIST1 ------LIST2 LIST3 LIST1+LIST2 LIST2+LIST3 LIST1+LIST3 LIST1+LIST2+LIST3
03jul1987 09sep1943....
I would like to create a dummy variable in the return dataset for every list of dates that is 1 when the corresponding date is equal to one of the dates in one list. For example: if 02jan1986 is a date contained in list1 but not in the other lists, the first dummy variable dummy variable should be 1 and all the other variables should be zero for that return and that date.
My solution would be to create a esparated dta file for every list, create a dummy variable which is always equalt to one, rename the list of date as "DATE" and merge the return database (the first one) with this new database for every list of dates, so that at the end I would have 1 for the dates that match and a missing value otherwise, so that the dummy variable I desire would be basically done. However, in trying to do this,
merge m:1 DATE using Listofdate1.dta
I got the error: variable DATE does not uniquely identify observations in the using data. The every list of dates has unique values, except for the last four lists, which are combinations of the former original lists. However, I get this error even if I use a list with unique values. DATE is not unique in the database I start with.
Hope someone can help
Thank you in advance
Comment