Good Evening All,
I have a hierarchy which has holes in it as per the HAVE dataset code below. I am looking to first maintain the right most populated value whilst filling all blanks to the left (the code attached with the Array does this nicely). Then I need to find the right most populated record and hold it's value until ORG_LVL_10. I am struggling with the finding a solution that performs the latter task. Any help would be greatly appreciated.
Thank you for all your help.
Regards,
Scott
data have; length org_lvl_1 org_lvl_2 org_lvl_3 org_lvl_4 org_lvl_5 org_lvl_6 org_lvl_7 org_lvl_8 org_lvl_9 org_lvl_10 $20.; infile datalines dlm= ',' dsd missover; input org_lvl_1 org_lvl_2 org_lvl_3 org_lvl_4 org_lvl_5 org_lvl_6 org_lvl_7 org_lvl_8 org_lvl_9 org_lvl_10; datalines; LEVEL1,LEVEL2,LEVEL3,LEVEL4,LEVEL5,LEVEL6,LEVEL7,LEVEL8,LEVEL9,LEVEL10 LEVEL1,LEVEL2,LEVEL3,LEVEL4,LEVEL5, LEVEL1,LEVEL2,LEVEL3,LEVEL4,,LEVEL6,LEVEL7,LEVEL8,LEVEL9,LEVEL10 LEVEL1,LEVEL2,LEVEL3,LEVEL4,,LEVEL6,LEVEL7,,,LEVEL10 ; run; data want; length org_lvl_1 org_lvl_2 org_lvl_3 org_lvl_4 org_lvl_5 org_lvl_6 org_lvl_7 org_lvl_8 org_lvl_9 org_lvl_10 $20.; infile datalines dlm= ',' dsd missover; input org_lvl_1 org_lvl_2 org_lvl_3 org_lvl_4 org_lvl_5 org_lvl_6 org_lvl_7 org_lvl_8 org_lvl_9 org_lvl_10; datalines; LEVEL1,LEVEL2,LEVEL3,LEVEL4,LEVEL5,LEVEL6,LEVEL7,LEVEL8,LEVEL9,LEVEL10 LEVEL1,LEVEL2,LEVEL3,LEVEL4,LEVEL5,LEVEL5,LEVEL5,LEVEL5,LEVEL5,LEVEL5, LEVEL1,LEVEL2,LEVEL3,LEVEL4,LEVEL6,LEVEL6,LEVEL7,LEVEL8,LEVEL9,LEVEL10 LEVEL1,LEVEL2,LEVEL3,LEVEL4,LEVEL6,LEVEL6,LEVEL7,LEVEL10,LEVEL10,LEVEL10 ; run; DATA test;
SET have;
ARRAY _ORG $ ORG_LVL_1 - ORG_LVL_10;
J=1;
DO I=1 TO DIM(_ORG);
PUT I = J = _ORG(I) = _ORG(J) =;
IF TRIM(LEFT(_ORG(I))) NE "" THEN DO;
_ORG(J) = COALESCEC(TRIM(LEFT(_ORG(J))),TRIM(LEFT(_ORG(I))));
J+1;
END;
END;
RUN;
... View more