Unless your locals
launchdatemo
launchdateyr
are defined the loop sees just
det
which is, as stated, ambiguous. It is more difficult to
say how to do what I think you want to do.
The crunch is that each time around each loop any local macro has to
evaluate to one string value. What you are hoping is that
it can, simultaneously, evaluate to several string values,
one of which will be chosen in each of several cases.
but there is no way this can happen.
I suspect you need at least one more loop to this.
Also I guess wildly that your data structure is quite
the wrong way round to do much easily in Stata. Solve
this problem, and other problems will be just as messy.
Consider reshaping to panel data structure, and much
may be a lot easier.
You need a really thorough knowledge of quite what local
macros are and can do, based on careful reading of [U].
Nick
[email protected]
Terra Curtis
> I have a question regarding the `x' notation. I've looked through the
> Statalist archive and found some hints but I can't seem to
> make it work how I want.
>
> I have a forvalues loop I'm trying to run:
>
> forvalues x=1989(1)2005 {
> forvalues y=1(1)12 {
> if `x'==2005 & `y'>8 continue
> gen
> mktgprof`y'`x'=(det`y'`x')/(det`launchdatemo'`launchdateyr')
> }
> }
>
> And when I run that I get the following error:
> det ambiguous abbreviation
> r(111);
>
> end of do-file
> r(111);
>
> After some experimenting I know that the problem lies in
> the(det`launchdatemo'`launchdateyr') part. I need the
> denominator to refer
> to, for example, the variable det11989 if launchdate (one of
> my variables)
> for that observation is equal 1/1/1989. I have created two variables,
> launchdatemo and launchdateyr which are the launch date month
> and year,
> respectively. That's what I'm trying to refer to in the
> denominator above.
> Is there some other way or some other notation I can use to
> refer to these values?
*
* 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/