I am really not clear with what all flag# refer to. Similarly, if col1 = apple and col3 = apple then flag1 = 0, flag2 = 0, flag3 = 1 Shouldn't the above that you've given as an example have flag1=1, flag2=0, flag3=1 ? How do you go about if col1=col4 and col2=col3? Should you only have flag4=1 and all other flags=0 because you mentioned the pointer should've been moved to 4 from there? Taking my example up there again and adding a few things - note that since flags don't already exist and you can use relative dimensions to create arrays, you would need to use like a proc sql on dictionary.columns to figure get the flag count to be created in a macro variable first. For simplicity at this point, I'll use a %let flagdim %let flagdim=50; data want; set have; array dt {*} dt: ; array flag {*} flag1-flag&flagdim. (&flagdim.*0); /* initiate all flags to 0 instead of missing */ flag=0; do i=1 to (dim(dt)-1); if dt(i) = dt(i+1) then do; flag(i) = 1; i+1; end; /* give flag=1 to current dt if the immediate successor is equal else it should be given to the other dates' flag??? */ else do j=i+1 to (dim(dt)) until (flag(j)=1); if dim(i) = dim(j) then do; flag(j) = 1; i=j+1; end; end; end; run; I still really am not clear on how you are defining your flags. The example I copied above where you say if dt(1)=dt(3) only flag(3) should be equal to 1 is really not a usual approach to flagging. Shouldn't they both be flagged? Why is the later dt flagged when its not the immediate successor of the former dt() but the former dt() is flagged when its immediate successor is equal? What are you looking to achieve with your flags afterwards? Maybe their definition isn't completely clear and we could help with that as well. Looking back at your example again if col1 = apple and col3 = apple then flag1 = 0, flag2 = 0, flag3 = 1 If col4 is not equal to apple, will you then replace flag3 with a 0?
... View more