I can't find a way to summarize the same variable using different weights. I try to explain it with an example (of 3 records): data pippo;
a=10;
wgt1=0.5;
wgt2=1;
wgt3=0;
output;
a=3;
wgt1=0;
wgt2=0;
wgt3=1;
output;
a=8.9;
wgt1=1.2;
wgt2=0.3;
wgt3=0.1;
output;
run; I tried the following: proc summary data=pippo missing nway;
var a /weight=wgt1;
var a /weight=wgt2;
var a /weight=wgt3;
output out=pluto (drop=_freq_ _type_) sum()=;
run; Obviously it gives me a warning because I used the same variable "a" (I can't rename it!). I can do it but just for one variable: proc summary data=pippo missing nway;
var wgt1-wgt3 /weight=a;
output out=pluto (drop=_freq_ _type_) sum(wgt1-wgt3)=a1-a3;
run; But if I introduce a second variable I can't use that trick proc summary data=pippo missing nway;
var wgt1-wgt3 /weight=a; var wgt1-wgt3 /weight=b; <---- WRONG!!!
output out=pluto (drop=_freq_ _type_) sum(wgt1-wgt3)=a1-a3 sum(wgt1-wgt3)=b1-b3;<---SAME NAME, WRONG!!!
run; I've to save a huge amount of data, I've not so much physical space and I should construct like 120 field (a0-a6,b0-b6 etc) that are the same variables just with fixed weight (wgt0-wgt5). I want to store a dataset with 20 columns (a,b,c..) and 6 weight (wgt0-wgt5) and, on demand, processing a "summary" without an intermediate datastep that oblige me to create 120 fields. Due to the huge amount of data I'd like also not to use proc sql statement (even because I've to write it manually for each variable): proc sql;
create table pluto
as select sum(db.a * wgt1) as a1, sum(db.a * wgt2) as a2 , etc.
quit; Is There a "Super proc summary" that can summarize the same field with different weights? Thanks in advance, Paolo
... View more