|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: modifying a macro containing variable names
In the code below, I attempt to take a global macro containing variable
names and use a loop to remove each variable one at a time and perform
some calculations with the remaining variables. Something goes wrong,
however, with the list. As indicated below, the modified list looks
correct in the display command, but I do not get the expected word
count, and I am unable to run any estimation commands on the modified
list. I've searched the archives for related issues and tried every
combination of quotation marks and spaces that I can think of, but still
no luck . . .
Perhaps the error messages from the last two lines hold the clues, but I
can't decipher them. Any help you can offer would be appreciated.
Thanks,
Jeremy
P.S. If it matters, my goal is to calculate predicted values after
xtreg, fe, allowing each variable to go from low to high while holding
the others at their means.
est restore mm_men3
global ivlist "occ_1 occ_2 occ_3"
foreach var of varlist $ivlist{
local list1 regexr("$ivlist", "`var'", "")
local list2 : list retokenize list1
di `list2' /*list2 looks:
okay: occ_2 occ_3*/
local numvars : word count (`list2')
di `numvars' /*a double-check
shows that the word count is not 2 as expected, but 7*/
*adjust `list2', xb by(`var') /*if this line is run, the
error message is: time-series operators not allowed */
*sum `list2' /*if this line is
run, the error message is: "occ_1 occ_2 occ_3 invalid name*/
}
--
********************
Dr. Jeremy Reynolds
Associate Professor
Undergraduate Coordinator
Department of Sociology
117 Baldwin Hall
University of Georgia
Athens, GA 30602-1611
Phone: (706) 583-8072
Web: http://uga.edu/soc/people/faculty/reynolds_jeremy.php
Fax: (706) 542-4320
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/