Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Generate Start and End Dates for SMCL Log Reports |
Date | Thu, 20 Sep 2012 15:37:44 +0100 |
su date, meanonly di "This analysis runs from " %tdd/N/CY r(min) " to " %tdd/N/CY r(max) 1. The minimum and maximum are just numeric constants, and can be derived using -summarize-. Creating new variables to hold constants, and then transferring their values to scalars, are all unnecessary. 2. To get the -format- you want, you need to study the help for -dates and times-. 3. Scalars and macros don't have inherent or intrinsic formats that can be assigned, but you can instruct -display- to use the format you need. 4. This list is Statalist, not StatList. Nick On Thu, Sep 20, 2012 at 3:23 PM, Kristina Beatrice Benavidez <beatricestata1711@gmail.com> wrote: > 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 > appearance? > > I cannot find a way to get to the sentence I need without having to look up > the startdate and enddate everytime. > * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/