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

st: A tricky case (tricky to me)


From   Jia Xiangping <[email protected]>
To   statalist <[email protected]>
Subject   st: A tricky case (tricky to me)
Date   Tue, 11 Oct 2005 03:00:06 +0800

Dear all,

I came accross a very tricky problem (to me it's tricky, maybe not to you).

Table1 is the data in table form. The first variable is the index of
plot(it's meaningless here). The second is the area of each plot of
land, with the variable "crop" being the type of crops planted in
specific plot. So var2, var12, var22, var32..are categorical variables
and they are not exlusive. That means they might be the same code.

TABLE 1
plot     area      crop  ..........
1         var1      var2
2         var11    var12
3         var21    var22
4         var31    var32
5         var41    var42
.............

TABLE  2
crop ........areax(the variable I want to generate now)
xvar1        areax1
xvar4
..........
Table2 only provide some of crops.

Here I want to generate the variable areax (in TABLE2) that is the
area of specific crop, say, xvar1. The following is the work I did:
//gen areax1
gen areax1=0
forvalues i=1(10)999 {
local j=`i'+1
replace areax1=areax1+var`i' if var`j'=xvar1
}

Then I was informed that invaled syntax
r(198);
end of do-file
r(198)

Can some one tell me what's wrong?


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



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