I have a dataset similar to the one shown below, where I have transposed the data in chrongical order based on date. My dates will be different every time though.. since I will be running a query everyday so the dates will update. For each ID, I need to subtract the latest date( amount)- First date (amount)/ First date to find the percentage of change over that time period. SO for ID1 ( 138-0)/0 but I will need to set this to 100% for ID2 (149-145)/145. data test; input ID sasdate date9. amount; format sasdate date9.; datalines; 1 01FEB2014 123 1 01MAR2014 138 2 01JAN2014 145 2 01FEB2014 155 2 01MAR2014 149 3 01JAN2014 133 3 01FEB2014 132 3 01MAR2014 129 ; run; proc sort data=test; by id sasdate; run; proc sql; select distinct cats('_',put(sasdate,date9.)) into :alldates separated by ' ' from test order by sasdate; quit; %put &alldates; proc transpose data=test out=outx1 (drop=_name_); by id; var amount; id sasdate; idlabel sasdate; run; data outx1; retain id &alldates; set outx1; run; proc print data=outx1 label noobs ; title 'Transposed dates in chronological order'; run;
... View more