Statalist


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

st: RE: help with mata's st_sview


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: help with mata's st_sview
Date   Sat, 4 Jul 2009 17:11:36 +0200

<>

As -help mf_st_view, mark(remarks5)- says: "Assignment does not cause
promotion." Note that you execute Stata commands, such as the -recast-
command,  from within -mata- as in - help mata stata-




HTH
Martin

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Mike Wazowski
Sent: Samstag, 4. Juli 2009 05:43
To: statalist@hsphsun2.harvard.edu
Subject: st: help with mata's st_sview

dear statalisters,

i am puzzled by the following behavior:

i use st_sview to access a stata variable and change it internally within
mata.  however, i am not able to "stretch" a string variable above its
storage type, for example, "make" in auto.dta is stored as str18 but if i
want to change it within mata to something longer than 18 chars, the new
string gets truncated to 18 chars.  the following code illustrates this
behavior:

sysuse auto, clear
keep in 1/5
list make
d make
mata:
st_sview(x,.,"make")
x[.,.]=x*2
x
end
list make
replace make = "01234567890123456789" in 1
list make

as you can see, when i issue -replace- in stata, "make" is automatically
promoted to str20.

how can i promote a sting var from within mata to a longer string?

thanks,

mike

ps. the same behavior happens with st_sstore:

sysuse auto, clear
keep in 1/5
list make
d make
mata:
st_sstore(2,"make","01234567890123456789")
end
list make







      


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

*
*   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   |   What's new   |   Site index