You can use the DO REPEAT command to loop through lists of variables. The following is an example of using this command to create a date before and after a date to compare and increment the counter variable when the two variables are different.
data list fixed / observation (A1). begin data 1 2 3 4 5 end data. *making random data. vector week(52). do repeat week = week1 to week52. compute week = RND(RV.UNIFORM(0.5,4.4)). end repeat. execute. *initialize count to zero. compute count = 0. do repeat week_after = week2 to week52 / week_before = week1 to week51. if week_after <> week_before count = count + 1. end repeat. execute.
source share