Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: generate stata variables in mata and set the names from matrices


From   Cyrus Levy <levy.cyrus@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: generate stata variables in mata and set the names from matrices
Date   Fri, 29 Apr 2011 05:05:14 -0500

I want to generate stata variables in mata, and set the names of those variables using a mata matrix. I use the code below which is supposed to work -it works when I enter the lines line by line-, but then when I run it in a do file, it doesn't work. It doesn't generate a HHI_R50 variable. It generates a HHI_R variable with no extension referring to the corresponding matrix value. What's wrong?

...
mata
...
radian=(50,75,200)
  for (rd=1; rd<=cols(radian); rd++) {
...
        st_matrix("radian", radian)
        st_numscalar("rd", rd)
        stata(`"local namer=radian[1,rd]"')
        stata("gen HHI_R`namer'=.")
        st_store(., "HHI_R`namer'", HHI_R)
}
end
...

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index