I want the data to be transposed (date) and arranged accordingly and fillin gaps Eg:
/*COUNT ID BASED ON bucket and Sold_month*/
PROC SQL;
CREATE TABLE want AS
SELECT bucket, Sold_month,COUNT(ID) as IID from TRANS_2 GROUP by bucket,
Sold_month;
quit;
/*Format date*/
proc datasets ;
modify want;
FORMAT Sold_month YYMMN6.;
quit;
/*TRANSPOSE*/
PROC TRANSPOSE data=want out=wantf (drop=_:) prefix=D_ ;
by bucket;
var IID;
id Sold_month;
format IID best.;
run;
/*Sorting the dates Sold month*/
proc contents data=wantf out=col_names(keep=name) noprint;
run;
proc sort data=col_names out=col_names_sorted;
by name;
run;
proc sql;
create table col_names_sorted_n as
select name from col_names_sorted where name<>'bucket';
run;
data _null_;
set col_names_sorted_n;
by name;
retain sorted_cols;
length sorted_cols $2500.;
if _n_ = 1 then sorted_cols =name ;
else sorted_cols = catx(' ', sorted_cols, name);
call symput('sorted_cols', sorted_cols);
run;
%put &sorted_cols;
/* Final SOLD DATA- */
data output_sorted;
retain bucket &sorted_cols;
set wantf ;
run;
/*ADDING 0 to missing values*/
proc stdize data=output_sorted out=Transaction reponly missing=0;
run;
This works but I dont get the missing column names and rows which I want to get by seeing the maximum and minimum values of bucket(0-max) and sold_dt(all year_month from min year-month to max year-month). I dont want to manually enter all the columns/buckets but derive the max and min and do. But bucket should start from 0 to max available