help for dtastamp (Roger Newson)

Store current date and time in dataset characteristics

dtastamp [ , dformat(format_name) tformat(format_name) ]

Description

dtastamp stores the current date and time in the dataset characteristics
_dta[datestamp] and _dta[timestamp].
This is useful if the user then saves the current dataset to a disk file,
and later wants to know approximately when the file was created.

Options

dformat(format_name) specifies a format to be used for creating the date stamp
from a Stata internal format date numeric value.
If absent, then it is set to %tddd_Mon_CCYY.

tformat(format_name) specifies a format to be used for creating the time stamp
from a Stata internal format datetime/C numeric value.
If absent, then it is set to %tCHH:MM:SS.

Remarks

Stata stores creation dates and times in datasets in disk files
(see help for file formats dta),
and displays these dates and times if the user uses the describe command.
However, it is not easy for users to access these dates and times for use in their own programs.
descgen allows the user to give the dataset a date stamp and a time stamp in dataset characteristics,
which the user can later access and use.
In particular, the user may use the SSC package xdir
to create a dataset in memory with one observation for each of a list of disk datasets,
and then use the SSC package descgen
to add variables containing dataset attributes,
using the option charlist(datestamp timestamp)
to create variables containing the date and time stamps.
The packages xdir and descgen can be downloaded from SSC.

dtastamp gets the current date and time from the creturn results c(current_date) and c(current_time).
This limits the precision of the time to the nearest second (plus execution delay).

Examples

Set-up:

. sysuse auto, clear

. describe, full

. char list

The following example saves the default date and time stamps
in the dataset characteristics _dta[datestamp] and _dta[timestamp],
respectively.

. dtastamp

. char list

The following example saves non-default format date and time stamps
in the dataset characteristics _dta[datestamp] and _dta[timestamp],
respectively.

. dtastamp, dformat(%tdCCYY/NN/DD) tformat(%tCHH.MM.SS)

. char list

Author

Roger Newson, Imperial College London, UK.
Email: r.newson@imperial.ac.uk

Also see

Manual: [P] char, [D] datetime

On-line: help for char, datetime

help for xdir, descgen if installed