Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Generate Start and End Dates for SMCL Log Reports

From   Kristina Beatrice Benavidez <>
Subject   st: Generate Start and End Dates for SMCL Log Reports
Date   Thu, 20 Sep 2012 15:23:20 +0100

Hi StatListers,

I have numerous analysis SMCL log files to create.

One of my datasets runs from 16/07/2012 until 20/08/2012.

These date observations are in the date variable and is in "DMY" %td format.

In the log file, I need to write the sentence: "This analysis runs from
16/07/2012 to 20/08/2012."

I would like to do this without having to manually look at the dataset to
find the startdate (16/07/2012) and enddate (20/08/2012) because I'll have
to do this across many datasets.

How would I do this?

I tried
. egen startdate = min(date)
. egen maxdate = max(date)
. format startdate & enddate %td

I tried to make the first observation of the startdate variable (there is
only one startdate so the observations across the startdate variables are
all the same) so that I can then put this in the SMCL log file:

. scalar startdatescal = startdate[1]

However, the result gives me 19190 which is the stata date number and does
not appear as the %td date format.

How do I perhaps transform the startdate and enddate variable formats from
elapsed date to non-elapsed date whilst still keeping the date format

I cannot find a way to get to the sentence I need without having to look up
the startdate and enddate everytime.

Any help would be appreciated.

Kind regards,

Beatrice Benavidez
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index