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

st: -foreach-, local macro, -split- command

From   David Torres <[email protected]>
To   [email protected]
Subject   st: -foreach-, local macro, -split- command
Date   Tue, 08 Sep 2009 17:31:48 -0400

Okay, I would say I'm about to pull out my hair, but since I don't have any I will spare you the cliche.

I have a minor problem working with a local macro created within a loop command (-forv-), which is followed by another loop command (-foreach-). This is the deal:

1.  I lead with a -levelsof- command, then store the values in a local macro.
2. I call the local macro in a -foreach- command, replacing a previously generated variable with the values therein. 3. My values are actually strings and take up a bit of space within the one variable created for them (Stata only allows up to 244 characters for string variables). This means that some of the values don't get recorded. 4. The -split- command works wonderfully at creating a different variables for the multiple responses recorded into the single variable filled from my local macro.

My question is this: Is there some way I can call the values in my local macro and record them into different variables without having to fill the limited space Stata allows in a variable?

I guess this would be a one-to-many split, but without a variable to actually split. The information for splitting would be stored in another form or something.

If I have 5000 students who have each scored differently on IQ scales at several times over several years and their position in the distribution are stored as strings (mentally retarded, borderline, low normal, etc.), some of the observations will, when called in the -foreach- command, exceed the 244 character limit.

This is sort of what I'm doing:

levelsof wais, local(lev)
foreach l of lev {
  replace generatedvar="`l' "...

split generatedvar

Everything else works fine; I'm just missing those values (strings and portions thereof) in excess of 244 characters.



David Diego Torres

*   For searches and help try:

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