Thanks, Thomas. Alas it does not work that well in my case. And it's
not because there is a space after _Iquarter_. Now I just copied and
pasted each one of your command lines, just to be sure, and:
*--------------------------*
. clear
. set obs 3
obs was 0, now 3
. gen _Idate_130 = 0
. rename _Idate_130 _Iquarter_92_2
. local qtr: display %tqY!_q 130
. di "`qtr'"
92_3
. gen _Idate_131 = 0
. rename _Idate_131 _Iquarter_`qtr'
92_3 not allowed
r(101);
*--------------------------*
I have no idea why this is happening on my Stata. (btw, Intercooled
Stata 9.2. for Macintosh).
davide
> Works fine for me.
> The implication of the error is that you must have had a space after
> _Iquarter_ and before `qtr'.
>
> Here's my test code:
>
> .. clear
> .. set obs 3
> obs was 0, now 3
>
> .. gen _Idate_130 = 0
> .. rename _Idate_130 _Iquarter_92_2
>
> .. local qtr: display %tqY!_q 130
> .. di "`qtr'"
> 92_3
>
> .. gen _Idate_131 = 0
> .. rename _Idate_131 _Iquarter_`qtr'
>
> .. desc
>
> Contains data
> obs: 3
> vars: 2
> size: 36 (99.9% of memory free)
> -------------------------------------------------------------------------------
> storage display value
> variable name type format label variable label
> -------------------------------------------------------------------------------
> _Iquarter_92_2 float %9.0g
> _Iquarter_92_3 float %9.0g
> -------------------------------------------------------------------------------
> Sorted by:
>
> ..
>
>
> -----------------------------------
> Thomas J. Steichen
> [email protected]
> -----------------------------------
*
* 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/