Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Generate Start and End Dates for SMCL Log Reports


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Generate Start and End Dates for SMCL Log Reports
Date   Mon, 24 Sep 2012 10:06:00 +0100

Should be

di "Old ORN - NO Activities - NEW sample - ALL rooms - " %tdd/N/CY
`min' " to " %tdd/N/CY `max' " - NO package"

On Mon, Sep 24, 2012 at 9:29 AM, Nick Cox <[email protected]> wrote:
> r-class results get overwritten by results from the next r-class
> command, and -log- is one such. Look at the help for -log- to see
> this.
>
> In your case you can save the results after -summarize- to use them
> when needed.
>
> su date, meanonly
> local min = r(min)
> local max = r(max)
> log on
> di "Old ORN - NO Activities - NEW sample - ALL rooms - " %tdd/N/CY
> `min' " to " %tdd/N/CY `max)' " - NO package"
>
> In this case
>
> local min `r(min)'
> local max `r(max)'
>
> or
>
> local min "`r(min)'"
> local max "`r(max)'"
>
> or any combination would work as well.
>
> Nick
>
>
> On Mon, Sep 24, 2012 at 7:21 AM, Beatrice Benavidez
> <[email protected]> wrote:
>> Hi Nick,
>>
>> Thanks for that and thanks for clearing things up.
>>
>> I have another question regarding displaying this in a log smcl report file.
>>
>> I tried doing two things to display the start and end date information.
>>
>> #1
>>
>> " su date, meanonly
>>
>> log on
>>
>> . di "Old ORN - NO Activities - NEW sample - ALL rooms - " %tdd/N/CY
>> r(min) " to " %tdd/N/CY r(max) " - NO package"
>> Old ORN - NO Activities - NEW sample - ALL rooms -          . to
>>    . - NO package
>>
>> log off"
>>
>> The start and end dates appear blank.
>>
>> #2
>>
>> "log on
>>
>> . su date, meanonly
>>
>> . di "Old ORN - NO Activities - NEW sample - ALL rooms - " %tdd/N/CY
>> r(min) " to " %tdd/N/CY r(max) " - NO package"
>> Old ORN - NO Activities - NEW sample - ALL rooms - 16/07/2012 to
>> 20/08/2012 - NO package
>>
>> log off"
>>
>> The results do not appear blank but my issue with the above is that I
>> do not want the lines to appear in the log file:
>> "su date, meanonly"
>> and 'di "Old ORN - NO Activities - NEW sample - ALL rooms - "
>> %tdd/N/CY r(min) " to " %tdd/N/CY r(max) " - NO package"'
>>
>> It seems that "su date, meanonly" must immediately precede the 'di
>> "Old ORN - NO Activities - NEW sample - ALL rooms - " %tdd/N/CY r(min)
>> " to " %tdd/N/CY r(max) " - NO package"' statement?
>>
>> I would ideally like my log file to look like this:
>>
>> log on
>>
>> Old ORN - NO Activities - NEW sample - ALL rooms - 16/07/2012 to
>> 20/08/2012 - NO package
>>
>> log off
>>
>> Any help would be appreciated.
>>
>> Kind regards,
>>
>> Beatrice
>>
>> On 20 September 2012 15:37, Nick Cox <[email protected]> wrote:
>>> 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
>>> <[email protected]> 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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index