我有以下数据集,我希望将变量'summary'转换并创建为变量
Date serNo source summary OrderNo
28SEP2017 101 CO Number 123
28SEP2017 101 CO City Albany
输出数据集应该类似于
Date serNo source Number City
28SEP2017 101 CO 123 Albany
有人可以帮忙吗?
答案 0 :(得分:3)
by Proc sql
proc sql;
select distinct date, serno, source,
max(case when summary = 'Number' then Orderno end) as Number,
max(case when summary = 'City' then orderno end) as city
from have
group by date, serno, source;
或通过proc转置
proc sort data=have ;
by date serno source;
run;
proc transpose data=have out=want(drop = _name_);
by date serno source;
id summary;
var orderno;
run;