Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: RE: looping up to a local macro
From
Michael Costello <[email protected]>
To
[email protected]
Subject
Re: st: RE: looping up to a local macro
Date
Thu, 23 Jun 2011 10:38:14 -0400
Wow, this became a much bigger thing than I was anticipating! Thanks
for all the interest though. I guess I'm wondering if I am thinking
of the local macro correctly, in that it's a kind of proxy for some
value (in my case 50, 100, etc) which can have operations done unto
it, or if it's something else that I don't understand.
I manage ~30 databases. Most of them need the same bits of code run
on them, but each has a different number of variables upon which that
code must be run. For example:
Database 1 has variables letter1, letter2, letter3, . . . , letter100
Database 2 has variables letter1, letter2, letter3, . . . , letter50
I would like to create this "master cleaning file" which, after
establishing a local macro value of either 50 or 100, would do the
following:
**Section: Letter Names**
egen letter_score2=rowtotal(letter1-letter`letters'), missing
egen letter_attempted=rownonmiss(letter1-letter`letters')
gen letter_score_pcnt=letter_score/`letters'
gen letter_score_zero= (letter_score==0) if letter_score<.
gen letter_attempted_pcnt=letter_score/letter_attempted
gen clpm=round(letter_score/(1-(letter_time_remain/60)))
But the error I'm getting is: "letter_sound ambiguous abbreviation"
for the first line of the code
Sarah, the error i'm getting when I try to run a loop is "invalid syntax"
forvalues i = 1(1)`letters' {
quietly: rename letter0`i' letter`i'
quietly: recode letter`i' (9=.) (2=1) (1=0)
* more lines of code here
}
invalid syntax
--
Michael Costello
"To call in the statistician after the experiment is done may be no
more than asking him to perform a post-mortem examination: he may be
able to say what the experiment died of." -Sir Ronald Aylmer Fisher,
FRS
*
* 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/