|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: -foreach-, local macro, -split- command
I have read this and responses several times, but am still not
convinced that I get the original layout of the data. So maybe
there's a good reason you can't do this:
levelsof wais, local(lev)
local i=1
foreach l of lev {
generate str time`i'="`l'"
local i++
}
?
hth,
Jeph
David Torres wrote:
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.
Thanks,
--------------------------------------------
David Diego Torres
*
* 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/
*
* 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/