初めてSASコードを調べるSQL開発者として、私は提供されたスクリプトのセクションを理解するのに苦労しています。SASからSQLへの変換
誰でも次のことを説明できますか、可能であれば、SQLに相当するものを説明できますか?
* sum up the total 6 months value for customers with positive value and quantity of items;
proc summary data=value_last6_positive nway missing;
var saleprice quantity;
class Cardid ;
output out = value_last6_s (drop=_type_ _freq_)
sum(saleprice)=saleprice
sum(quantity)=quantity;
run;
* rank them;
proc sort data=value_last6_s;
by saleprice;
run;
data count;
set value_last6_s;
count=1;
run;
proc sort data=count;
by count;
run;
data count2;
set count;
by count;
if first.count then rank=1;
else rank+1;
if rank=<544139 then decile=10;
else if rank=<544139*2 then decile=9;
else if rank=<544139*3 then decile=8;
else if rank=<544139*4 then decile=7;
else if rank=<544139*5 then decile=6;
else if rank=<544139*6 then decile=5;
else if rank=<544139*7 then decile=4;
else if rank=<544139*8 then decile=3;
else if rank=<544139*9 then decile=2;
else decile=1;
run;
proc freq data=count2;
table decile;
run;
proc means data=count2;
var saleprice;
class decile;
run;
私は限りCardID
でグループ化された売上データの集計を使用して構造(CardID, SalePrice, Quantity)
を持ってvalue_last6_s
の一時テーブルと同等の構築として持っています。どのように進めるかわからない。前もって感謝します。
編集:最初のproc summary
ブロックの
マイ変換:
-- value_last6_s
SELECT CardID,
SUM(SalePrice) SalePrice,
SUM(Quantity) Quantity
INTO #value_last6_s
FROM #value_last6_positive
GROUP BY CardID
ORDER BY SUM(SalePrice);
私は確認することはできませんが、私はそれが正の値とアイテムの数量... – RQDQ
@RQDQのおかげで、非常に有用との顧客のための総6ヶ月の値を合計すると思います。 –
申し訳ありません - 私は抵抗できませんでした。 :-)あなたはこれまでにどのようなSQLを開発しましたか? – RQDQ