Date: Fri, 12 Jan 2007 11:35:07 -0500
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: help for proc sql
Content-Type: text/plain; charset=ISO-8859-1
proc sql;
select distinct a, b, max(c=11) as c11, max(c=22) as c22, max(c=33) as c33
from have
group by a, b;
quit;
a b c11 c22 c33
-------------------------------------------
1 2 1 1 1
2 3 1 1 0
3 4 1 0 1
On Fri, 12 Jan 2007 11:28:59 -0500, Jane <program.sas@GMAIL.COM> wrote:
>I have a dataset like this
>
>data have;
>input a b c;
>datalines;
>1 2 11
>1 2 22
>1 2 33
>2 3 11
>2 3 22
>3 4 11
>3 4 33
>;;
>run;
>
>I want to output like this:
>a b 11 22 33
>---------------------
>1 2 1 1 1
>2 3 1 1 0
>3 4 1 0 1
>
>Here is my proc sql code;
>
>proc sql;
>select distinct a, b, c=11 as c11, c=22 as c22, c=33 as c33
>from have; quit;
>
>but the output is:
> a b c11 c22 c33
> ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
> 1 2 0 0 1
> 1 2 0 1 0
> 1 2 1 0 0
> 2 3 0 1 0
> 2 3 1 0 0
> 3 4 0 0 1
> 3 4 1 0 0
>Thanks
>Jane
|