Statalist The Stata Listserver


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

st: Another spss do if-translation-problem


From   Schneider Julia <Julia.Schneider@iab.de>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: Another spss do if-translation-problem
Date   Tue, 31 Oct 2006 10:34:41 +0100

Good morning,

Could anybody advise me how to translate the following do if-condition from SPSS to STATA? I tried to use replace (but it did not work the way I tried to). Could I use if... else if... else?

Thanx for your help!
Julia

****

Here is the original spss-syntax:

 					compute hrolle=caseid/100000.
 					exec.


 					do if hrolle<200.
 					compute hrolle=hrolle-100.
 					else.
 					compute hrolle=hrolle-200.
 					end if.
 					exec.

 					do if hrolle<20.
 					compute hrolle=hrolle-10.
 					else if hrolle < 30.
 					compute hrolle=hrolle-20.
 					else.
 					compute hrolle=hrolle-30.
 					end if.
 					exec.

 					compute rolle=trunc(hrolle).
 					exec.

 					formats rolle (F1).
 					Exec.

 					And the failed version in stata with replace:

 	***

 	gen hrolle=caseid/100000
 	replace hrolle=hrolle-100 if hrolle<200
 	replace hrolle=hrolle-200 if hrolle>=200
 	replace hrolle=hrolle-10 if hrolle<20
 	replace hrolle=hrolle-20 if hrolle<30
 	replace hrolle=hrolle-30 if hrolle>=30

 	gen rolle=trunc(hrolle)



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