Hello Community,

I hope someone can help me out with my Stata problem.

Basically, I would like to subtract two points in time form one another (insterTime - startTime), using an identifier variable (ID) as well as several conditions (received Message = 1 and Typ).

Here is an excerpt from my data:

Array

I thought something along the following lines could work, but I simply do not know enough about coding in Stata:

{(itemInster if Typ == Hotel) – (ItemStart – 5 days if Typ == Flug)} if recivedHotelMissing ==1 & id match

Ideally, Stata would give me something like this:

Array

Thank you in advance