Analyzing unbalanced panel / Autocorrelation

I have a DataFrame containing an unbalanced panel data set with individual-year observations characterized by an :id and :year. I would like to compute the autocorrelation of variable X at the individual :id level but so far could not figure out a way to do it.
For those familiar with Stata, what I’d like to do is something like:
tsset id year
cor X L.X

Any tips are appreciated!