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]

From |
annoporci <annoporci@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: generate variable versus define scalar, with conditional statement |

Date |
Tue, 15 Jan 2013 22:25:56 +0800 |

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

yes, I see, absolutely, I did try this also: scalar newscalar = open[3jan2012]

Your suggestion to: su `var' if date == mdy(1,3,2012), meanonly scalar `var'_ini = r(min) works inside my loop over the list of variables `var', so that's what I'm using now That's better than generating mostly-missing variables, I'm sure. thanks Nick! On Tue, 15 Jan 2013 22:07:42 +0800, Nick Cox <njcoxstata@gmail.com> wrote:

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 <annoporci@gmail.com> wrote:you write faster than I think Nick![...] I need to beable 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/

-- Patrick Toche. * * 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/

**Follow-Ups**:**Re: st: generate variable versus define scalar, with conditional statement***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: generate variable versus define scalar, with conditional statement***From:*Maarten Buis <maartenlbuis@gmail.com>

**References**:**st: generate variable versus define scalar, with conditional statement***From:*annoporci <annoporci@gmail.com>

**Re: st: generate variable versus define scalar, with conditional statement***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: generate variable versus define scalar, with conditional statement***From:*annoporci <annoporci@gmail.com>

**Re: st: generate variable versus define scalar, with conditional statement***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: generate variable versus define scalar, with conditional statement***From:*annoporci <annoporci@gmail.com>

**Re: st: generate variable versus define scalar, with conditional statement***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**st: SEM becomes unidentified when introducing single item control variables** - Next by Date:
**Re: st: generate variable versus define scalar, with conditional statement** - Previous by thread:
**Re: st: generate variable versus define scalar, with conditional statement** - Next by thread:
**Re: st: generate variable versus define scalar, with conditional statement** - Index(es):