Hi! I have a dataset with minute data (stock price) which I would like to convert into 30min data intervals. Im not very familiar with Stata but I try to learn it with my thesis. The data is reported in unix time. I have done the following commands:

rename timestamp unixtime
generate double statatime = unixtime * 1000 + mdyhms(1,1,1970,0,0,0)
generate double statatime2 = unixtime * 1000*30 + mdyhms(1,1,1970,0,0,0)
collapse close,by(statatime2)

Variable close = close price

Statatime2 gives me intervals of 30 minutes but the dates are clearly wrong. How do I get my 30 min intervals to respond to the right unixtime? Or is it another more effiecient way to convert my 1 minutes data into 15 min intervals? A step-by-step instruction would be highly preciated!

Thanks for any help!