06-13-2013 04:47 PM
Hi- I'm new to this form, I have been looking into this for a long time with no success. I need to write a sas code that loop through all the columns and return ID and the Value from Col(x) where Col(x+1)-Col(x) > 1.
The output would be like this:
|1||2||(since Col4 - Col3 >1)|
|2||10||the last column in case there are no gaps|
|3||0||(since Col2-Col1 >1)|
06-13-2013 04:53 PM
Create an array and loop through it using a break statement to stop at the first difference.
You'll want to start your loop at two and go from there.
06-13-2013 05:00 PM
Since you're from Microsoft land and I don't want you to hate SAS here's some untested code:
array col(10) col1-col10;
do i=2 to 10 while (flag ne 0);
if col-col[i-1]>1 then do;
06-13-2013 05:12 PM
i is the variable counter, so its an interger 1 to 10.
I just noticed that you're using VBA array counting though, 0 to 9 ish, so you may want to use i-1 instead...you can test it out.