Hi SAS wizards, I have a list of customers and 24 month columns(mo1, mo2...) in front of each. Each can take values from 1 to n. However this 'n' is unique for each row only. For e.g. for customer A (say n=4), mo1=1, mo2=2, mo3=2, mo4=2, mo5=3, mo6=4 and so on til mo24. I want to count how many times this value changes across the 24 months for each customer (i.e. in this 6 month period in the example, the count would be 3). I understand the logic of doing it but don't how to code it in using macros/data step/loops etc in SAS. The logic I have is: Initiate a counter at 0 and a ref as mo1 value. Check this ref vs mo2, mo3 etc sequentially and increase counter when value is different while also updating ref as the new value. Return the Counter value at the end for each row/customer.
... View more