[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: workaround for macro length problem with levelsof() ?

From   Keith Dear <>
Subject   Re: st: workaround for macro length problem with levelsof() ?
Date   Sun, 24 Feb 2008 09:35:05 +1100

Instead of
local filepath = "c:/mydata/`name'"
try simply
local filepath c:/mydata/`name'

The point is that the = unnecessarily evaluates the subsequent expression as a string, before assigning it to the local macro, and strings are indeed limited to 244 characters (this has come up here several times recently).

Also instead of -clear-, -drop _all- may be enough. I don't know if it matters here.

At 08:56 AM 24/02/2008, you wrote:


I am trying to access a series of files using the values of a variable in
another dataset to as an index of the names of the files.  This is easy to
do with ­levelsof-, except that the macro is truncated at a very small
number of characters (244?).

Here is what I’d like to do:

insheet using sp_components.csv
keep v1
levelsof(v1), local(namelist)

foreach name of local namelist {
        local filepath = "c:/mydata/"`name'"
        insheet using "`filepath'"

Since I need to clear memory each time, there is no easy workaround that I
can see using -forvalues-
I can't help but think that -levelsof- wouldn't bother to generate the nice
long list that it does if there weren't some way to use it.  Am I missing



Internal Virus Database is out-of-date.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.20.7/1283 - Release Date: 2/16/2008
2:16 PM

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index