## Make some data to show the technique df <- data.frame( ccode = rep(1:5, each=25), year = 1980:2004, x = round(rnorm(125, 0, 4)) ) # create vector of observation numbers in dataset df$obs <- 1:nrow(df) # create country-year variable cy <- paste(df$ccode, df$year, sep=".") # create country-lag-year variable lcy <- paste(df$ccode, df$year-1, sep=".") # define the lagged observation df$lagobs <- df$obs[match(lcy, cy)] ## cbind x and the one-period lag of x cbind(df$x, df$x[df$lagobs])