Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Date: Wed, 18 Apr 2007 10:08:42 -0500


From   "Maarten Buis" <[email protected]>
To   <[email protected]>
Subject   st: RE: Date: Wed, 18 Apr 2007 10:08:42 -0500
Date   Wed, 18 Apr 2007 17:12:23 +0200

forvalues i = 1/50 {
use "c:\datasets\RDSim\expanded.dta", clear
keep if sim == `i'
sort z
by z: egen wgt=sum(n)
cs y x [fw=n], by(z) standard(wgt) rd
}

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology 
Vrije Universiteit Amsterdam 
Boelelaan 1081 
1081 HV Amsterdam 
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434 

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Garth Rauscher
Sent: woensdag 18 april 2007 17:08
To: [email protected]
Subject: st: Date: Wed, 18 Apr 2007 10:08:42 -0500

I am mostly a sas user but use stata occasionally for analyses, particularly
if I want to do a standardization.
Below is working code to estimate a Z-standardized risk difference for the
effect of X on Y, on a subset of the dataset RDSim (where sim==1)

use "c:\datasets\RDSim\expanded.dta", clear
keep if sim == 1
sort z
by z: egen wgt=sum(n)
cs y x [fw=n], by(z) standard(wgt) rd


Id like to repeat the above program for each value of sim (from 1-50), using
efficient programming. I'd like to loop through the program 50 times for
each value of sim, but I am not proficient enough at Stata to figure out how
to do this. I tried forvalues and foreach but couldn't get either to work.
Does anybody have a simple solution to this problem they'd be willing to
share?

Thanks, Garth

Garth Rauscher
Assistant Professor
SPH Epidemiology and Biostatistics
University of Illinois at Chicago
1603 W Taylor St (M/C/ 923)
Chicago, IL 60612
(312) 413-4317 phone
(312) 996-0064 fax
[email protected] <mailto:[email protected]>  email

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

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