【发布时间】:2017-09-28 13:23:15
【问题描述】:
/*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;
这可行,但我没有通过查看 bucket(0-max) 和 sold_dt(all year_month 从 min year-month 到 max year-month) 的最大值和最小值来获得我想要获得的缺失列名和行.我不想手动输入所有列/存储桶,而是导出最大值和最小值并执行。但是bucket应该从0开始到最大可用
【问题讨论】:
标签: sas