有人可以帮助将此PROC SQL代码转换为数据步骤吗?我希望数据步骤会更快。我是从SAS-EG生成此代码的,所以我还不够熟练。
谢谢 杰夫
PROC SQL;
CREATE TABLE WORK.'APPAREL NEWNESS 01'n AS
SELECT DISTINCT t2.outletfamily AS outletfamily,
t2.itemid,
t2.itemnumberunsuppressed AS itemnumber_unsuppressed,
t2.ppmonth,
/* Dollars */
(SUM(t2.totalvalue)) FORMAT=DOLLAR20. AS Dollars,
/* Units */
(SUM(t2.unitssold)) FORMAT=COMMA20. AS Units,
/* Proj Dollars */
(SUM(t2.proj_totalvalue)) FORMAT=DOLLAR20. AS 'Proj Dollars'n,
/* Proj Units */
(SUM(t2.proj_unitssold)) FORMAT=COMMA20. AS 'Proj Units'n
FROM APLSWP.vw_aplmlwk_fact_nat_nc_uns t2
GROUP BY t2.outletfamily,
t2.itemid,
t2.itemnumberunsuppressed,
t2.ppmonth;
QUIT;
答案 0 :(得分:2)
GROUP BY
和SUM
的功能可以在proc summary
或类似但功能更丰富的proc means
中使用。不幸的是,我没有SAS许可证,因此无法为您提供代码。寻找在proc means
here中解决您的问题的示例。GROUP BY var1, var2, var3, var4
时,该过程将产生var1,var2,var3和var4值的不同组合。关键字DISTINCT
是不必要的。 答案 1 :(得分:0)
我建议改用PROC MEANS。没有样本数据,我无法确定这正是您要寻找的东西,但是应该可以使您接近:
proc means data=APLSWP.vw_aplmlwk_fact_nat_nc_uns noprint nway;
*CLASS = grouping variables;
class outletfamily itemid itemnumberunsuppressed ppmonth;
*VAR = list of variables to analyze (optional);
var totalValue UnitSold Proj_Total_value proj_unitssold;
*create output data set;
output out=want
/*list of summary statistics to save*/
sum(totalValue) = dollars
sum(UnitSold) = units
sum(Proj_Total_value) = 'Proj Dollars'n
sum(proj_unitssold) = 'Proj Units'n;
run;