Statalist


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

st: help with mata's st_sview


From   Mike Wazowski <[email protected]>
To   [email protected]
Subject   st: help with mata's st_sview
Date   Fri, 3 Jul 2009 20:42:55 -0700 (PDT)

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index