Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: mata stata() parameters


From   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: RE: mata stata() parameters
Date   Wed, 22 Aug 2007 23:21:52 -0400

Hello Thomas,

thank you for your reply. I know that I can get date and time from
Stata code. But I need to determine it within a procedure in Mata,
possibly without quering Stata (without having to use function stata()
). As it is described in another post here, macros are evaluated
during the compilation time, and this is the reason that my code does
not work as it is supposed to.

Thanks, Sergiy

On 8/22/07, Steichen, Thomas J. <[email protected]> wrote:
> Date functions are in Stata 9.2. There is no need for Mata.
>
> For example,
>
> .. di c(current_date)
> 22 Aug 2007
>
>
> .. di month(d(`c(current_date)'))
> 8
>
> You can store this in a macro as
>
> .. local mth = month(d(`c(current_date)'))
> .. di `mth'
> 8
>
>
> -----------------------------------
> Thomas J. Steichen
> [email protected]
> -----------------------------------
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Sergiy Radyakin
> Sent: Wednesday, August 22, 2007 3:15 PM
> To: [email protected]
> Subject: st: mata stata() parameters
>
> Hello Statalisters,
>
> I am working with Stata 9.2 and I need to get today's day, month and
> year. Since these functions were introduced in Stata 10 and not
> available in Stata 9.2 I am calling Stata from inside mata to retrieve
> the components of today's date:
>
> stata("local _AAA=month(d(`c(current_date)'))",1,1)
> mc=strtoreal(st_local("_AAA"))
>
> This code produces the result I want, e.g. mc becomes equal to 8.
> However, after compiling the procedure into an .mo file, I can see
> that the call is stored as:
>
> local _AAA=month(d(22 Aug 2007))
>
> note that 22 Aug 2007 is today's date. There seems to be no difference
> whether I specify no-macro-expansion parameter or not.
>
> Where is a mistake? (I want the compiled code to access current date,
> not the date when it was compiled).
>
> Thank you,
>       Sergiy Radyakin
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
> -----------------------------------------
> CONFIDENTIALITY NOTE: This e-mail message, including any
> attachment(s), contains information that may be confidential,
> protected by the attorney-client or other legal privileges, and/or
> proprietary non-public information. If you are not an intended
> recipient of this message or an authorized assistant to an intended
> recipient, please notify the sender by replying to this message and
> then delete it from your system. Use, dissemination, distribution,
> or reproduction of this message and/or any of its attachments (if
> any) by unintended recipients is not authorized and may be
> unlawful.
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index