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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: new Stata package -lstrfun- lets you modify long local macros that contain strings using Mata string functions


From   Dan Blanchette <dan.blanchette@duke.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: new Stata package -lstrfun- lets you modify long local macros that contain strings using Mata string functions
Date   Mon, 16 Aug 2010 10:54:21 -0400 (EDT)

Dear Statalist Members,

Thanks to Kit Baum, a new Stata package -lstrfun- is now available for download from the SSC:

  . ssc install lstrfun


Description

  -lstrfun- allows you to modify local macros that contain strings using Mata's
  string functions which are not restricted to the maximum length of strings
  in Stata like the normal string functions in Stata are limited.  For example:

  If the length of the local macro m_test is 1,234 and you want to make it all
  uppercase and you use the Stata string function upper():

    . local m_test= upper(m_test)

  then Stata will truncate m_test to the first 244 characters.  -lstrfun- will
  not truncate m_test:

    . lstrfun m_test, upper(`"`m_test'"')

  If you are using Stata SE or Stata MP, then your setting of maxvar affects the
  maximum number of characters in a macro.  The maximum number of characters in
  a macro is only 1,081,511 when maxvar is set to 32767.  Stata's c-class values
  will show you what your Stata session's limits are set to:

    . display c(maxvar)
    5000

    . display  %11.0gc c(macrolen)
    165,200

    . set maxvar 27000

    . display  %11.0gc c(macrolen)
    891,200

  -lstrfun- can be very helpful when trying to modify value labels and notes in
  Stata since values labels and notes are allowed to have more characters than
  normal string functions are allowed to handle.

Here is the help page for -lstrfun- in html format that shows all the string functions -lstrfun- can use to modify a local macro or create a new local macro:

   http://fmwww.bc.edu/repec/bocode/l/lstrfun.html

Let me know if you have any questions,

Dan Blanchette
Research Associate
Center for Entrepreneurship and Innovation
Duke University's Fuqua School of Business
dan.blanchette@duke.edu





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