Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[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 <>
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'
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 <> wrote:
> Perhaps you mean characteristics. See -help extended_fcn-.
> Nick
> 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:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index