I found this to be an interesting exercise and wanted to give it a whirl. I'm working in a UNIX environment so I wondered what happened with the file information and compare that to the SAS Data Set metadata information. I have a macro called %UNIX_STAT that runs a stat command on a given file and writes the results to a named SAS data set. Details include atime (last access date-time), mtime (last modified date-time), and ctime (last change date-time). I rename those to ACCESS_DATE, MODIFY_DATE, and CHANGE_DATE. The results were interesting. In my case, I noticed that the unix file data matched the START TIME of the data step, where the SAS metadata for CRDTE and MODTE marked the END TIME of the data step. One could use this information to develop further the process of recording and measuring start time, end time, and run time of a data step. However, those times would only reflect "real time" and not necessarily point to efficiency in a shared environment: cpu usage, swap, and other measures could come in to play. The results on a windows or other environment may vary. Here's my test: 31 *test data set ; 32 %put DATETIME=%sysfunc(datetime(), datetime.) ; DATETIME=12APR25:23:39:36 33 data mydata ; 34 do i = 1 to 10 ; 35 sleep = sleep (5, 1) ; 36 output ; 37 end ; 38 run ; NOTE: The data set WORK.MYDATA has 10 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 50.02 seconds cpu time 0.02 seconds 39 %put DATETIME=%sysfunc(datetime(), datetime.) ; DATETIME=12APR25:23:40:26 40 41 %macro datatimer (data) ; 42 %local data dsid crdte modte rc ; 43 %let dsid = %sysfunc(open(&data)) ; 44 45 %if &dsid %then %do ; 46 %let crdte = %sysfunc(attrn(&dsid, crdte), datetime.) ; 47 %let modte = %sysfunc(attrn(&dsid, modte), datetime.) ; 2 The SAS System 22:19 Saturday, April 12, 2025 48 %let rc = %sysfunc(close(&dsid)) ; 49 %end ; 50 51 %put &=crdte &=modte ; 52 %mend datatimer ; 53 54 %datatimer (mydata) ; CRDTE=12APR25:23:39:36 MODTE=12APR25:23:39:36 55 56 %unix_stat (file=%sysfunc(pathname(work))/mydata.sas7bdat, out=stat) ; NOTE: The data set WORK.STAT has 1 observations and 13 variables. NOTE: MACRO %UNIX_STAT used: real time 00:00.14 cpu time unknown 57 58 data _null_ ; 59 set stat ; 60 put access_date= modify_date= change_date= ; 61 run ; access_date=12APR25:23:40:26 modify_date=12APR25:23:40:26 change_date=12APR25:23:40:26
... View more