SAS INTERVIEWS CONCEPTUAL QUESTIONS
We have a SAS data set:
Product Order_Date
A 13jan2015
14jan2015
15jan2015
16jan2015
B 14jan2014
17jan2015
C 20jan2014
21jan2104
22jan2014
We need the output like:
Product Order_Date
A 13jan2015
A 14jan2015
A 15jan2015
A 16jan2015
B 14jan2014
B 17jan2015
C 20jan2014
C 21jan2104
C 22jan2014
- data one11;
infile datalines dsd missover dlm=',';
input name$ Order_Date date9.;
format Order_Date:date9.;
datalines;
A,13jan2015
,14jan2015
,15jan2015
,16jan2015
B,14jan2014
,17jan2015
C,20jan2014
,21jan2104
,22jan2014
;
run;
data two2(drop=z);
set one11;
RETAIN Z '';
IF name ='' THEN name=z;
else z=name;
RUN;
SET ONE;
RETAIN Z;
IF PRODUCT NE ' ' THEN Z=PRODUCT;
RUN;
PROC PRINT DATA=TWO;
VAR PRODUCT ORDER_DATE;
FORMAT ORDER_DATE DATE9.;
RUN;