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

st: Re: Basic Commands


From   "Jun Xu" <[email protected]>
To   [email protected]
Subject   st: Re: Basic Commands
Date   Wed, 05 May 2004 14:29:00 -0500

Just to corrent my awkward syntax here:


preserve
set obs 200 // if obs <200
local var1lbl "all the vavalues of country"
local var2lbl "all the values of year"
gen country=.
gen year=.
gen cntvar3=.

local i = 1
foreach var1val in `var1lbl' {
foreach var2val in `var2lbl' {
replace country = `var1val' if _n =`i'
replace year = `var2val' if _n=`i'
count var3
replace cntvar3 = r(N) if _n=`i'
local ++i
}
}

keep if _n<=200
keep country year cntvar3
save whereever

restore

_________________________________________________________________
MSN Toolbar provides one-click access to Hotmail from any Web page � FREE download! http://toolbar.msn.com/go/onm00200413ave/direct/01/

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