Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: indirect evaluation of variables


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: indirect evaluation of variables
Date   Mon, 31 Mar 2003 16:01:09 +0100

b. water
> 
> thanks for your reply. i am writing as someone who uses 
> stata pragmatically 
> first and foremost while learning more stuffs on the side 
> (e.g. macros and 
> do's, programming is further down the road). so if you feel 
> you prefer not 
> to further the discussion on this particular topic, i do 
> not mind as the 
> alternative command line instruction works. it's just your 
> macro that did 
> not work and am trying to understand why it did not work as 
> a learning 
> experience for me.
> 
> i have changed the data bleen to b1een as in b(one)een 
> rather than blee as 
> in b(l for lima)een and correspondingly changed all 
> ambigious looking l to 1 
> (as in changing all l(lima)'s and 1(one)'s to 1(one)'s so 
> that there's no 
> ambiguity. correspondingly, i have changed the command line 
> instruction to:
> 
> gen b1ob = cond(b1een == "ing", b1ing, b1am)
> 
> i.e. changing all the l(lima)'s to 1(one)'s
> 
> this worked.
> 
> then i run the macro, again changing all the l(lima)'s and 
> 1(one)'s to 
> 1(one)'s just so there's no ambiguity, and i got the same 
> error message.
> 
> 
> . drop b1ob
> 
> . do "C:\My Documents\untitled.do"
> 
> . gen b1ob = .
> (4 missing values generated)
> 
> . forval i = 1 / `= _N' {
>   2. replace b1ob = b1`= `b1een'[`i']' in `i'
>   3. }
> b11 not found
> r(111);
> 
> end of do-file
> r(111);
> 
> so, am still puzzled but if you prefer to leave it at that, 
> i'll leave it at 
> that. thanks for your input.

Sorry: this hinges on typos whereby what 
I sent to Statalist differed from what I used 
(which, as said, does work). 

My code was, in effect, 

clear 
input str3 bleen bling blam 
"ing"      1    11
"am"       2    12
"ing"      3    13
"ing"      4    14
end  
gen blob = . 
forval i = 1 / `= _N' { 
	replace blob = bl`=bleen[`i']' in `i' 
} 
list

That is, there are no extra quotes around 

bleen 

Nick 
[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/



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