Hi,

I am using long form data. I have a variable called ia_label that defines an area of interest and a variable called rankIA that gives the order in which that area of interest was accessed by participants. I want to create a third variable that defines, for each area of interest, what was the next area of interest that was accessed. Example of data below:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int participant str11 ia_label float(rankIA nextIA)
2 "Label 3" 3 .
2 "Label 2" 2 .
2 "Label 1" . .
end
An example of what I am aiming for is as follows:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int participant str11 ia_label float rankIA str7 nextIA
2 "Label 3" 3 ""      
2 "Label 2" 2 "Label 3"
2 "Label 1" . "Label 2"
end
Any thoughts on this would be much appreciated.