[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
John-Paul Ferguson <jpferg@MIT.EDU> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st:variables named T099`j' |

Date |
Wed, 18 Jun 2008 16:24:33 -0400 |

Dear Mandy,

I think that trying to manipulate j within the "if" statement on your fourth

line is causing the problem. If you first create another local macro that's

equal to that value and include it, the loop should work correctly. See below:

local j 0802

forvalue i=1/8 {

g age`i'=2006-T099`j'

local k = `j'-1

replace age`i'=2006-T099`j'-1 if T099`k' > 5

local j = `j' + 500

}

I am assuming that the first "T099`j'-1" in the "replace" line is supposed to be

the value of T099`j' minus 1, not the value of T099`k' as defined here. Adjust

accordingly.

Best,

John-Paul Ferguson

MIT

Quoting Man Jia <jia.m@neu.edu>:

Hi all, In a loop I meant the variable name is T099`j'. But STATA treat only T099 as the variable name. I have tried [T099`j'],but it didn't work. I was wondering if anyone could give me some help. Thanks a lot! The following are variable names: T0990801 T0991301 T0991801 T0992301 T0992801 T0993301 T0993801 T0994301 T0990802 T0991302 T0991802 T0992302 T0992802 T0993302 T0993802 T0994302 I used the following command: --------------------------------------- local j 0802 forvalue i=1/8 { g age`i'=2006-T099`j' replace age`i'=2006-T099`j'-1 if T099[`j'-1]>5 local j = `j' + 500 } end -------------------------------------- Stata gives the following error information: T099 ambiguous abbreviation r(111); How should I let STATA know T099`j' or T099[`j'-1] is the variable name instead of only T099? Thanks for your kind help! Mandy Jia * * 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/

* * 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/

**References**:**st:variables named T099`j'***From:*Man Jia <jia.m@neu.edu>

- Prev by Date:
**Re: st: Re: Tabulate command ordering** - Next by Date:
**Re: st: error bars** - Previous by thread:
**st:variables named T099`j'** - Index(es):

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