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: passing indefinite no of arguments
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: passing indefinite no of arguments
Date
Mon, 2 Apr 2012 23:04:57 +0100
Evidently, -date- is a Stata date variable, so although you see
05jan2010 it is a numeric variable and you can check the first value
directly.
. di mdy(1,5,2010) + 1
18269
The program does what you asked for -- you specify some variables, you
get a row total of the rest -- and also exactly what I warned you
against, that if the rest are not homogeneous that will break it as
far as you are concerned.
Also, a do-file does not take options.
Nick
On Mon, Apr 2, 2012 at 9:37 PM, tashi lama <[email protected]> wrote:
>
>
> I am sorry. I had used r[] instead of r[]. Looks like it is working although I am not sure if it is giving me the right result.
>
>
>
> date var_34 var_50 var_90
> 05jan2010 2 1 1
> 06jan2010 3 2 4
> 07jan2010 4 8 5
> 08jan2010 5 4 3
> 09jan2010 6 3 2
>
>
>
>
>
> so I invoked sumrest var_34 var_50, generate(g), I got
>
>
>
> date var_34 var_50 var_90 g |
> |----------------------------------------------|
> 1. | 05jan2010 2 1 1 18268 |
> 2. | 06jan2010 3 2 4 18272 |
> 3. | 07jan2010 4 8 5 18274 |
> 4. | 08jan2010 5 4 3 18273 |
> 5. | 09jan2010 6 3 2 18273 |
> +----------------------------------------------+
>
>
>
> Any idea? Also, when I run this as a do file, I get option generate() not allowed....
>
>
>
> Thank you....
>
> ----------------------------------------
>> Date: Mon, 2 Apr 2012 20:32:09 +0100
>> Subject: Re: st: passing indefinite no of arguments
>> From: [email protected]
>> To: [email protected]
>>
>> I tested it and found two bugs. Please try this
>>
>> program sumrest
>> version 8.2
>> syntax varlist(numeric) [if] [in] , Generate(string)
>> marksample touse, novarlist
>> qui count if `touse'
>> if r(N) == 0 error 2000
>> confirm new var `generate'
>> unab all : _all
>> local varlist : list all - varlist
>> local varlist : list varlist - touse
>> egen `generate' = rowtotal(`varlist') if `touse'
>> end
>>
>>
> &#!
> 10;>
>> On Mon, Apr 2, 2012 at 8:20 PM, tashi lama <[email protected]> wrote:
>> > Hello Nick,
>> >
>> >
>> >
>> > I tried running the code with syntax as a do file. There was an error which reads option generate() not allowed. Any idea?
>> >
>> >
>> >
*
* 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/