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 <>
To   "''" <>
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!


Here is the original spss-syntax:

 					compute hrolle=caseid/100000.

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

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

 					compute rolle=trunc(hrolle).

 					formats rolle (F1).

 					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:

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