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: New package -specialexp- on SSC
From
Matthew White <[email protected]>
To
[email protected]
Subject
st: New package -specialexp- on SSC
Date
Fri, 29 Nov 2013 22:29:35 -0500
Thanks as always to Kit Baum, a new Mata function -specialexp()- is
now available for download from SSC. To install, type -ssc install
specialexp- in Stata.
-specialexp()- obtains an expression that evaluates to a specified
string. It can facilitate writing do-files that contain difficult
string literals.
To be used in an expression, most strings need only be enclosed in
double quotes. However, strings that contain the Stata special
characters `, $, or " or an ASCII control character, such as the
line-feed character (\n), may also need the \ escape character. They
may even require an expression that contains multiple strings.
Here are a few examples:
: specialexp("abc")
"abc"
: s = "`" + "x" + "'"
: s
`x'
: specialexp(s)
"\`x'"
: s = "`\" + `"\${x}""y"""' + "`"
: s
`\${x}""y""`
: specialexp(s)
"\`\" + `"\${x}""y"""' + "`"
Best,
Matt
--
Matthew White
Senior Project Associate
Innovations for Poverty Action
101 Whitney Avenue, New Haven, CT 06510 USA
www.poverty-action.org
*
* 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/