Hello group,
I have approximately 90 datasets. The datasets contain costumer data for each day (3 months data). The datasets have the same variables and are saved as cvs files. They are saved in the same directory (location) and have consistent names (ex. APRIL 1 2016, APRIL 2 2016, etc). We do not have daily data for holidays so some dates can be skipped. Each dataset file is label with the corresponding date but inside the dataset there is not a date variable. My goal is to append the datasets but first I need to generate a date variable for each dataset. I can import the dasets and generate the date variable individually for each dataset but I was wondering if there is a more efficient way to do this, perhaps a loop. I would appreciate any help. Thank you!
I have approximately 90 datasets. The datasets contain costumer data for each day (3 months data). The datasets have the same variables and are saved as cvs files. They are saved in the same directory (location) and have consistent names (ex. APRIL 1 2016, APRIL 2 2016, etc). We do not have daily data for holidays so some dates can be skipped. Each dataset file is label with the corresponding date but inside the dataset there is not a date variable. My goal is to append the datasets but first I need to generate a date variable for each dataset. I can import the dasets and generate the date variable individually for each dataset but I was wondering if there is a more efficient way to do this, perhaps a loop. I would appreciate any help. Thank you!
Code:
clear cd "H:\Daily Data" // select directory import delimited "H:\Daily Data\APRIL 1 2016.csv", bindquote(strict) case(preserve) clear // import data gen str str_TodaysDate="1April2016" // gen date variable gen double TodaysDate=date(str_TodaysDate,"DMY") format TodaysDate %td drop str_TodaysDate save 4_1_2016.dta, replace
Comment