Hi all, I have a data set consisting of an ID and six ordered numerical columns (Largest, Second, Third, ... Sixth). Have: ID Largest Second Third Fourth Fifth Sixth 1 98 97 96 85 70 1 2 77 0 0 0 0 0 3 61 55 0 0 0 0 4 44 30 12 0 0 0 Is there a way, in a Data step (or some other means), to get the non-zero values to replace the zero values in order, and in some cases repeat? See example below. Also, apologies if this has been answered elsewhere! My search fu may be a little lacking. Want: ID Largest Second Third Fourth Fifth Sixth 1 98 97 96 85 70 1 2 77 77 77 77 77 77 3 61 55 61 55 61 55 4 44 30 12 44 30 12 I've tried some IF THEN ELSE IF logic in a Data step which doesn't seem to stick. Any help is certainly appreciated! DATA Want;
SET Have;
IF SECOND=0 AND THIRD=0 AND FOURTH=0 AND FIFTH=0 AND SIXTH=0
THEN SECOND=Largest
AND THIRD=Largest
AND FOURTH=Largest
AND FIFTH=Largest
AND SIXTH=Largest;
ELSE IF SECOND ne 0 AND THIRD=0 AND FOURTH=0 AND FIFTH=0 AND SIXTH=0
THEN THIRD=Largest
AND FOURTH=SECOND
AND FIFTH=Largest
AND SIXTH=SECOND;
ELSE IF SECOND ne 0 AND THIRD ne 0 AND FOURTH=0 AND FIFTH=0 AND SIXTH=0
THEN FOURTH=Largest
AND FIFTH=SECOND
AND SIXTH=THIRD;
ELSE IF SECOND ne 0 AND THIRD ne 0 AND FOURTH ne 0 AND FIFTH=0 AND SIXTH=0
THEN FIFTH=Largest
AND SIXTH=SECOND;
ELSE IF SECOND ne 0 AND THIRD ne 0 AND FOURTH ne 0 AND FIFTH ne 0 AND SIXTH=0
THEN SIXTH=Largest;
RUN;
... View more