2
我想知道是否可以自動保存.do文件,以便它包含與我在.do文件內創建的日誌文件上的時間戳匹配的時間戳。例如,我開始每。做文件我得看起來像這樣:Stata:每次在do文件編輯器中執行.do文件時,是否可以使用時間戳自動保存.do文件?
#delimit ;
capture log close;
display _n(250);
*******Sets up the log for the output;
local a1=substr(c(current_time),1,2);
local a2=substr(c(current_time),4,2);
local a3=substr(c(current_time),7,2);
local b = c(current_date);
log using "H:\HSRE\Hospice Payment Reform\Plotzke\Ad Hoc Tasks\OY1\Monitoring for macs\Log\BPA Log (`b')`a1'_`a2'_`a3'", t;
<rest of the program>
display "Start: `starttime'";
display "End: " "$S_TIME";
log close;
有什麼我可以在節目的最後添加將保存我只是跑了。做文件(在.do文件編輯器中)帶時間戳(這樣我可以將代碼與日誌匹配)?
例如,目前我有一個文件:
"K:\Common\HSRE\Hospice Payment Reform\Plotzke\Ad Hoc Tasks\OY1\BenefitPeriodAnalysis\code\Benefit period analysis (Code).do"
如果我每次運行。做文件,它會保存這將是巨大的:
"K:\Common\HSRE\Hospice Payment Reform\Plotzke\Ad Hoc Tasks\OY1\BenefitPeriodAnalysis\code\Benefit period analysis (Code)(`b')`a1'_`a2'_`a3'.do"
[或一些變化]
謝謝!這是一個非常簡單的解決方案,可以滿足我的需求。 – user2992957