Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: macro string extraction


From   "Jamie Griffin" <[email protected]>
To   <[email protected]>
Subject   Re: st: macro string extraction
Date   Sun, 04 Sep 2005 14:03:19 +0100

You need the function _substr()_

local first=substr("hey",1,1)
local second=substr("hey",2,1)
di "`first'"
di "`second'"

See help functions  ->  string functions

Jamie Griffin

>>> [email protected] 09/04/05 8:06 am >>>
Hi all,

Does anybody knows how to extract a substring of an arbitrary string 
in order to place it into a macro?

More specifically, suppose i have a string "hey". I want the local
macro `first' to contain the string "h".

Can anybody recommend a way to do it?

In principle the macro extended function "piece" should do the trick,
however this function doesn't allow 1 1 (ones) as arguments (there is
a previous posting on this by StataCorp.)

Any help is greatly appreciated,
robert

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html 
*   http://www.stata.com/support/statalist/faq 
*   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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