Dear users,

I've been try (and struggling) to translate some SAS code to STATA. Unfortunately I don't see any guide on the web and I've not so much knowledge about SAS.
I'm wondering whether you can help me with this line of code to translate in STATA

In SAS I have the following statement

Code:
CASE WHEN varx = 1 or (varx = qtr(date)) THEN vary ELSE vary - lag.vary END as CAPEX
which, if I'm not mistaken is quite straightfoward in STATA:

Code:
gen CAPEX=.
replace CAPEX=vary if varx=1 | varx=qtr(date)
ELSE
replace CAPEX=vary- l.vary
The issue is that I don't know how to implement that ELSE statement in STATA.

Do you have any help on that? Many thanks