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

st: Generate


From   GLORIA ZAMBRANO ROZAS <gzambrano@minedu.gob.pe>
To   statalist@hsphsun2.harvard.edu
Subject   st: Generate
Date   Wed, 23 Feb 2005 10:25:23 -0500

Hi,
I am new in stata and want to generate several new variables, some of them
under  the same conditionals, something like this:

gen var1= varold01  if  ( nivel=1 & area=1 & sex=1)
gen var2=varold02   if ( nivel=1 & area=1 & sex=2)

gen var3= varold03  if  ( nivel=1 & area=2 & sex=1)
gen var2=varold02   if ( nivel=1 & area=2 & sex=2)

gen var4= varold04  if  ( nivel=1 & area=1 )
gen var5=varold05   if ( nivel=1 & area=2 )

I want to know if stata has a command that let me do something like this:

      if nivel=1 & area=1 then do;

                gen var2=varold02   if (sex=2)
                gen var4= varold04

       if nivel=1 and area=2 then do;

               gen var3= varold03  if  (  sex=1)
               gen var2=varold02   if (  sex=2)
               gen var5=varold05

that let me reduce the number of conditionals

Thanks
GZ

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