stata 当前日期时间作为文件名

发布时间 2023-05-30 08:59:01作者: myrj
global root="d:\statashu"
local wjm=subinstr(subinstr("`c(current_date)'",":","",.)," ","",.)
local year=year(date("`wjm'","DMY"))
local month= substr("00"+string(month(date("`wjm'","DMY"))),-2,2)
local day= day(date("`wjm'","DMY"))
local sj=subinstr(subinstr("`c(current_time)'",":","",.)," ","",.)
local wjma="`year'`month'`day'`sj'"
disp "`wjma'"
mkdir "`wjma'"
global work="$root\"+"`wjma'"
use chfs\chfs2015_hh_20191120_version14,clear
keep hhid track
keep if track==0
save $work\new1,replace