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 variable versus define scalar, with conditional statement


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: generate variable versus define scalar, with conditional statement
Date   Tue, 15 Jan 2013 14:07:42 +0000

It does work; it's just not what you want.

Stata is perfectly logical here.

scalar newscalar = open[mdy(1,3,2012)]

is

scalar newscalar = open[18995]

which will be missing or some value, depending on the size and details
of your dataset.

Stata is very good at syntax, but it's lousy at semantics. You want
Stata to be like a smart research assistant  and to look at
mdy(1,3,2012) and to realise what you _mean_, which is to go and find
the observation for that date, etc. Stata only notices what you _say_.

But no; Stata is a robot and just evaluates -mdy(1,3,2012)- as a pure
number, which is then treated as a subscript or observation number.
Again, that is what you said as far as it is concerned.

On Tue, Jan 15, 2013 at 1:47 PM, annoporci <[email protected]> wrote:
> you write faster than I think Nick!

[...] I need to be
> able to specify the date in a "human readable" way, so I tried:
>
>
> scalar newscalar = open[mdy(1,3,2012)]
>
>
> It doesn't work.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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