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]

st: -Matrix rownames- and local macro (operator invalid error)


From   Yeonsoo Kim <[email protected]>
To   [email protected]
Subject   st: -Matrix rownames- and local macro (operator invalid error)
Date   Wed, 5 Feb 2014 12:27:38 -0500

Dear Statalisters,

I get the "operator invalid" error when I try to input rownames for
the matrix. The matrix columns are the number of tests("flags") that
I'm running on each file in the directory folder and the rows are the
individual files whose names I want to put in the rownames.

Here is the output:

.  fs *.dta
ago_2008.dta  per_2010.dta  rus_2009.dta

.  local rows: word count `r(files)'

.  local cols = 161

.  di `rows'
3

.  matrix T = J(`rows', `cols', .)

.  di `r(files)'
ago_2008.dtaper_2010.dtarus_2009.dta

.  matrix rownames T = `r(files)'
ago_2008:  operator invalid
r(198);

Interestingly, similar codes for column names work:

.  local colnames = ""

.  forval i = 1 / 161   {
  2.    local colnames "`colnames' flag`i'"
  3.    }

.
.  matrix colnames T = `colnames'


What am I doing wrong?
*
*   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