We have a SAS data set:
Product Order_Date
A 13jan2015
14jan2015
15jan2015
16jan2015
B 14jan2014
17jan2015
C 20jan2014
21jan2104
22jan2014
W 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
www.sankhyana.com
Product Order_Date
A 13jan2015
14jan2015
15jan2015
16jan2015
B 14jan2014
17jan2015
C 20jan2014
21jan2104
22jan2014
W 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
Now prepare your Base SAS and Advance SAS Certification Exams with Online Mock tests: http://exam.sankhyana.com
www.sankhyana.com
DATA TWO(RENAME=(Z=PRODUCT) DROP=PRODUCT);
ReplyDeleteSET ONE;
RETAIN Z;
IF PRODUCT NE ' ' THEN Z=PRODUCT;
RUN;
PROC PRINT DATA=TWO;
VAR PRODUCT ORDER_DATE;
FORMAT ORDER_DATE DATE9.;
RUN;
data one11;
ReplyDeleteinfile 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;
Data a;
ReplyDeleteInfile datalines dsd dlm="";
Input @1 product $ 1. @3 order_date:date9.;
Format order_date date9.;
Datalines;
A 13jan2015
14jan2015
15jan2015
16jan2015
B 14jan2014
17jan2015
C 20jan2014
21jan2014
22jan0214
;
Run;
Data m;
Set a;
If order_date>='20JAN2014'd and order_date<='22JAN2014'd then product='C';
Else if order_date>='13JAN2015'd and order_date<='16JAN2015'd then product='A';
Else
Product ='B';
Run;