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

st: STATA equivalent to SAS subsetting "else if" statements?


From   "Deborah Garvey" <DGarvey@scu.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: STATA equivalent to SAS subsetting "else if" statements?
Date   Tue, 08 Jul 2003 11:50:19 -0700

Hello, all.

I have generally used SAS for data manipulation, so I am not familiar with the best way to code the equivalent of the subsetting "else if" statement in STATA.

This SAS code defines RACEETH hierarchically, based on the value of HISPANG and RACEG.  It only permits RACEETH to change once (from default missing to a valid value), at the first occurrence of a true IF statement:

if hispang = 0 then do;
  if raceg = 1 then raceeth = 1;
  else if raceg = 2 then raceeth = 2;
  else raceeth = 3;
  end;
else if hispang = 9 then raceeth = .N;
else if hispang ge 1 and hispang < 9 then raceeth = 7;

How do I accomplish this in STATA?

Your insights are appreciated,

Deb Garvey


******************************
Deborah Garvey, Ph.D.
Department of Economics
Kenna Hall
Santa Clara University
Santa Clara, CA  95053
408/554-5580
408/554-2331 (FAX)
dgarvey@scu.edu    
http://lsb.scu.edu/~dgarvey
**********************************


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