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" <>
To   <>
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;
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-2331 (FAX)

*   For searches and help try:

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