Statalist


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

RE: st: Length for strings, ignoring SMCL tags


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Length for strings, ignoring SMCL tags
Date   Tue, 2 Dec 2008 21:22:12 -0000

My diagnosis is the same. Or at least, I battered my head against this
and could think of nothing that suited. 

However, let's go one step back. Why do you want this? 

Nick 
n.j.cox@durham.ac.uk 

Austin Nichols

Brian Karfunkel <bkarfunkel@gmail.com>:
According to -help extended_fcn- you can't use display directives with
"in" and "as":

display in smcl "{err}hello"
loc g: display in smcl "{err}hello"
di strlen(`"`:display in smcl "{err}hello"'"')

which is unfortunate for your particular example. So you are stuck
removing all {smcl} before computing length--and during that process
counting spaces if you want them.

On Tue, Dec 2, 2008 at 3:58 PM, Brian Karfunkel <bkarfunkel@gmail.com>
wrote:

> Is there a way to get the length of a string while ignoring any SMCL
> tags in the string?
>
> In other words, I have "{err}hello", and I want the length of "hello",
> since the "{err}" tag doesn't affect the length as outputted.
>
> I've tried the following:
>
> strlen(`"`: display "{err}hello"'"')
>
> and variations thereof, but nothing seems to work. If there is a
> solution, it would also be helpful to know how it would treat "{col
> 30}hello" and "{space 20}hello", for example, in terms of whether the
> columns/spaces that are inserted are counted in the length (i.e.
> whether it is literally the number of characters of the line on the
> screen as displayed or if it is just the length of the string you'd
> get if you, say, -regexr-ed out all the tags in braces).

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