I am trying to execute some sytax to erase old archived input files that are two months old. I've placed a test file in my target archive folder, but it is not being erased. I've confirmed that the local for 'two months old' and my file name are in the same format and appear as 06May2024. Any advice on how to troubleshoot is appreciated.
Code:
*** 2.A Determining reference dates ******************************************** *** 2.A.1 Creating fake dataset to calculate dates of interest// Need today's date and two months ago// Using 9 weeks or 63 days ago (getting a target divisible by 7 for weekly automation)insobs 1 gen today = date(c(current_date),"DMY") gen twomonthsago = today - 63 format today twomonthsago %tdDDMonCCYY *** 2.A.2 Moving formatted dates into macros quietly summarize today, mean local today: disp %tdDDMonCCYY r(mean) quietly summarize twomonthsago, mean local twomonthsago: disp %tdDDMonCCYY r(mean) *** 2.B Managing Copies of the HAPI Files ******************************************** *** 2.B.1 Erasing file from two months ago, if it exists if fileexists("`fldr_archive'\*`twomonthsago'.csv")== 1 /// erase "`fldr_archive'\*`twomonthsago'.csv" else di "No archive file to erase"
Comment