Date: Mon, 3 Oct 2005 16:18:57 -0400
Reply-To: Ya Huang <ya.huang@AMYLIN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ya Huang <ya.huang@AMYLIN.COM>
Subject: Re: Outputting Ns of cells into different Vars TAB FREQ MEANS
data xx;
input a b;
cards;
1 1
1 1
1 2
1 2
1 3
1 3
1 3
2 1
2 2
2 2
2 3
3 1
3 1
;
data yy;
set xx;
by a;
if first.a then do; x1=0; x2=0; x3=0; end;
x1+(b=1);
x2+(b=2);
x3=(b=3);
if last.a;
run;
proc print;
run;
Obs a b x1 x2 x3
1 1 3 2 2 1
2 2 3 1 2 1
3 3 1 2 0 0
Kind regards,
Ya Huang
On Mon, 3 Oct 2005 13:06:46 -0700, toby989@HOTPOP.COM wrote:
>Hi All
>
>I want to create a summary of two variables, one with 100 levels, the
>other one with 3 levels, into a table that shows the Ns by cell. FREQ,
>TABULATE or MEANS procedure create one row for each level combination
>(100x3=300rows) and put the numbers into one variable, but for further
>processing, i need a dataset with 100 rows and 3 variables.
>
>I would be so grateful for your help on this.
>
>Thanks Toby
>
>
>1 1
>1 1
>1 2
>1 2
>1 3
>1 3
>1 3
>2 1
>2 2
>2 2
>2 3
>3 1
>3 1
>.
>.
>.
>99
>
>into
>
>1 2 2 3
>2 1 2 1
>3 2 ...
>.
>.
>99
|