/* test data */
data one;
input id time x $ y $;
cards;
1 1 a b
1 2 c d
1 3 e f
2 1 g h
2 2 i j
2 3 k l
2 4 m n
;
run;
/* create time pairs data within id */
proc sql;
select d1.id, d1.time as t1, d2.time as t2
, d1.x as x1, d1.y as y1
, d2.x as x2, d2.y as y2
from one as d1, one as d2
where d1.id = d2.id and d1.time < d2.time
order by id, t1, t2;
quit;
/* on lst
id t1 t2 x1 y1 x2 y2
--------------------------------
1 1 2 a b c d
1 1 3 a b e f
1 2 3 c d e f
2 1 2 g h i j
2 1 3 g h k l
2 1 4 g h m n
2 2 3 i j k l
2 2 4 i j m n
2 3 4 k l m n
*/
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.