|
On Fri, 9 Jan 2009 11:24:05 -0500, Hari Nath <hari_s_nath@YAHOO.COM> wrote:
>Hello all,
>
> Can somebody help me with proc tabulate.
> I have a dataset with variables b1,d1, b2,d2, b3,d3
> I will have to provide a summary on each of the variables.
>
> data x;
> b1=1;b2=1;b3=1;d1=2;d2=1;d3=8;output;
> b1=1;b2=3;b3=5;d1=2;d2=1;d3=8;output;
> run;
>
> proc tabulate data=x ;
> var b1 b2 b3 d1 d2 d3;
> tables b1 b2 b3 d1 d2 d3, sum;
> run;
>
> Even though the code above produces the correct output, I need to have
>the output in the format mentioned below.
>
> B D
> ID sum sum
> 1 2 4
> 2 4 2
> 3 6 16
>
> Thanks for your suggestions in advance
I might not take normalization to the degree that Toby did. After, all the
B's and D's might differ in nature and thus have different metadata. Here's
a compromise:
proc sql;
create view fortabul as
select 1 as ID, b1 as B, d1 as D from x
union all
select 2 , b2 , d2 from x
union all
select 3 , b3 , d3 from x
;
quit;
proc tabulate data=fortabul formchar=' ' noseps;
class id;
var b d;
table id , (b d) * sum * f=4. / rts=6;
run;
Result:
B D
Sum Sum
ID
1 2 4
2 4 2
3 6 16
|