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: Updating the value of a specific cll of a matrix using the value of a variable


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Updating the value of a specific cll of a matrix using the value of a variable
Date   Tue, 22 Nov 2011 16:08:38 +0000

You must subscript -counter- e.g. counter[1].

-display- indulges lack of subscripts and defaults to showing values
in observation 1. But -matrix- requires a subscript in this context.

Nick

On Tue, Nov 22, 2011 at 4:02 PM, Tatiana SOKOLOVA <[email protected]> wrote:
> I have created a double loop to generate counter variable values that will then be entered into an OUTPUT matrix. Everything except for 1 line seems to be working. The line is here:
>
>
>  matrix OUTPUT[`i', `j'] = counter
>
> * where i and j are the row and column indexes for the two loops and INPUT is defined as a 14x122 matrix
> *STATA writes: counter not found. But then I write:
> display counter
> * STATA shows the value of counter, say 4:
> 4
> *yet, if I use the same code and instead of the variable counter use a number, it works (the matrix OUTPUT is updated):
>  matrix OUTPUT[`i', `j'] = 4
> *I.e. the program does not recognize the variable counter when I want to udpate the matrix using its values. I have tried to use `counter' instead of counter but an error is reported again.
>

*
*   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/


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