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

Re: st: Implementing sas like array in Stata

From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: Implementing sas like array in Stata
Date   Mon, 25 Jul 2005 20:13:16 -0500

At 10:22 AM 7/26/2005 +1000, [email protected] wrote:
. local array1 "feleclsw finclo fintprtw flabour"
. local array2 "feleclsw_n finclo_n fintprtw_n flabour_n"
. local array3 "feleclsw_d finclo_d fintprtw_d flabour_d"
. local i = 1
. local n: word count `array1'
. while `i' <= `n' {
  2.        local var1 : word `i' of `array1'
  3.        local var2 : word `i' of `array2'
  4.        local var3 : word `i' of `array3'
  5.        replace `var1' = `var2' / `var3'
  6.        local i = `i'+1
  7. }
feleclsw ambiguous abbreviation
Do feleclsw and the other vars in array1 already exist prior to running this program? If not, then when Stata gets to the -replace-, it thinks you want to replace either feleclsw_n or feleclsw_d, and since it doesn't know which one it says you have an ambiguous abbreviation. It seems like you could do -gen- rather than -replace-; either that, or generate the 4 array1 variables first so they exist and can be replaced.

Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal):
WWW (department):

* For searches and help try:

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