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 <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: generate variable versus define scalar, with conditional statement
Date   Wed, 16 Jan 2013 14:32:46 +0000

It's certainly good technique.

. isid date

is another way to do it.

. tsset date

would also test uniqueness (literally!) of dates.

Nick

On Wed, Jan 16, 2013 at 12:35 PM, annoporci <annoporci@gmail.com> wrote:
>> Or, he can check if each date occurs at most once,
>> and simplify his code.
>>         bys date : assert _n == 1
>>         summ  open if date == mdy(1,2,2001), meanonly
>>         scalar newscalar = r(mean)
>
>
> In the present case, date is a unique identifier, but this is a great
> addition to my toolkit:
>
>
> bys date : assert _n == 1
>
*
*   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