Bookmark and Share

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]

Re: st: RE: How to get a list of the names of characters associated with a variable


From   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: RE: How to get a list of the names of characters associated with a variable
Date   Thu, 4 Mar 2010 16:20:12 -0500

Clyde Schechter:
Try this example:

prog lookfc
version 8.2
syntax [varlist], t(string)
foreach v of varlist `varlist' {
 loc c: char `v'[]
 loc nall 0
 foreach i of local c {
  loc j: char `v'[`i']
  loc k: subinstr loc j `"`t'"' "", all count(loc n)
  loc nall=`nall'+`n'
  }
 if `nall' > 0 {
  loc var `var' `v'
  }
}
if "`var'"!="" ds `var'
end
sysuse auto, clear
note mpg: inverse of good measure
lookfc, t(meas)

One problem with using index() or strpos() is that they will truncate
strings; according to -help limits-, the maximum length of the
contents of a characteristic is 8,681 characters for Small Stata and
67,784 characters for Stata/IC, Stata/SE, and Stata/MP.

On Thu, Mar 4, 2010 at 3:44 PM, Nick Cox <[email protected]> wrote:
> Perhaps you mean characteristics. See -help extended_fcn-.
>
> Nick
> [email protected]
>
> Clyde Schechter MA, MD
>
> I'm trying to write an ado file that will generalize the -lookfor-
> command
> so that it also searches for the target text in characters associated
> with
> variables.  (I need this because I have a data set with a large number
> of
> variables, and the key information is often found not in the label
> [which
> was truncated at 80 characters], but in a character--and the characters
> are not consistently named.)
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index