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

st: RE: not repeating the 'if' command


From   "Salah Mahmud" <salaheddin.mahmud@mcgill.ca>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: not repeating the 'if' command
Date   Fri, 1 Aug 2003 14:15:10 -0400

The closest thing to the SPSS filter is perhaps something like the
following:

preserve
keep if group==1

tab sex
tab race
etc....

restore

which you would then repeat for all levels of "group".

You can also try:

sort group
by group: tab sex
by group: tab race



Dr. Salaheddin Mahmud
Division of Cancer Epidemiology
Department of Oncology, McGill University
Gerald Bronfman Centre
546 Pine Avenue West
Montreal, Quebec
Canada H2W 1S6
Ph: (514) 398-8191.
Fax: (514) 398-5002.
Salaheddin.mahmud@mcgill.ca
 
 

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of Robert Bozick
> Sent: Friday, August 01, 2003 2:05 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: not repeating the 'if' command
> 
> I know that in SPSS there is way to set a filter for a series of
commands
> using a 'do if' statement.  Is there a way to do this in STATA?  For
> example, I want to perform a large set of analyses on a set of groups
> (group == 1....group == 50).  Do I have to continue to type if group
== 1
> after each command?  ex:
> 
> tab race     if group == 1
> tab sex      if group == 1
> tab race sex if group == 1
> 
> tab race     if group == 2
> tab sex      if group == 2
> tab race sex if group == 2
> 
> or, is there a way to globally set off group == 1 for all analyses
then a
> command to globally set off group == 2 for all analyses, and so on...?
> The above code seems too cumbersome.
> 
> 
> *
> *   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index