Use case example: in some cases, I'll check the timestamp of a CSV file, import the CSV only if it is newer than my DTA file, or skip the import step and use my existing DTA if the CSV is not newer.
For an example, I'll use a file found within BASE: arch.ado:
Code:
dir "C:\Program Files\Stata15\ado\base\a\arch.ado"
58.2k 2/23/19 20:56 arch.ado
My current solution:
Code:
tempfile dirCmdResult shell dir "`=subinstr("`c(sysdir_base)'", "/", "\", .)'a\arch.ado" > `dirCmdResult' import delimited `dirCmdResult', clear delimiters(tab) gen double timestamp = clock(v1, "MDY hm # #") // my Windows Regional Format is US mm/dd/yyyy hh:mm AP quietly: summarize timestamp local filesystemtimestamp `r(max)' di %tc `filesystemtimestamp'
23feb2019 20:56:00
But I'm assuming there must be a far simpler way to do this. Any advice will be appreciated.
Thank you,
Marc Peterson
0 Response to Obtain the timestamp of a file
Post a Comment