|Title||Current date and time|
Jeremy B. Wernow, StataCorp
David Kantor, Johns Hopkins University
You can put the current date and time into your log files by displaying the global macros where these values are stored.
. display "$S_DATE" 14 Feb 2003 . display "$S_TIME" 15:53:01 . display "$S_TIME $S_DATE" 15:53:17 14 Feb 2003
The current date and time are also available as part of the c() class, see [P] creturn.
. display c(current_date) 14 Feb 2003 . display c(current_time) 15:56:05 . display "`c(current_time)' `c(current_date)'" 15:56:32 14 Feb 2003
David Kantor suggests the following ado-file:
*! version 1.0 * Datetime procedure. Just displays the date and time. * Good for use in logged sessions. * By David Kantor. 9-26-97 version 7.0 program define datetime disp "DateTime: $S_DATE $S_TIME" end
It is then easy to include datetime in your do-files.
Classroom and web training
Teaching with Stata
Statalist: The Stata Forum
Last updated: 16 November 2022
StataCorp LLC (StataCorp) strives to provide our users with exceptional products and services. To do so, we must collect personal information from you. This information is necessary to conduct business with our existing and potential customers. We collect and use this information only where we may legally do so. This policy explains what personal information we collect, how we use it, and what rights you have to that information.
These cookies are essential for our website to function and do not store any personally identifiable information. These cookies cannot be disabled.
Please note: Clearing your browser cookies at any time will undo preferences saved here. The option selected here will apply only to the device you are currently using.