| Date: | Thu, 14 Jul 2005 12:44:24 -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: A question about proc transpose |
|
This will do:
data a;
input id1 id2 num;
datalines;
1 2 3
2 3 4
2 3 5
;
run;
data a;
set a;
by id1 id2;
if first.id2 then n=0;
n+1;
run;
proc transpose data=a out=c (drop=n);
by id1 id2 n;
var num;
run;
proc print data=c;
run;
On Thu, 14 Jul 2005 09:28:47 -0700, smartie_zhuo@HOTMAIL.COM wrote:
>Hi,
>Thanks in advance.
>I have a following program.
>
>
>data a;
>input id1 id2 num;
>datalines;
>1 2 3
>2 3 4
>2 3 5
>;
>run;
>proc transpose data=a out=c ;
>by id1 id2;
>var num;
>run;
>proc print data=c;
>run;
>
>The outcome has two col,"col1' and "col2".
>
> Obs id1 id2 _NAME_ COL1 COL2
>
> 1 1 2 num 3 .
> 2 2 3 num 4 5
>
>I know it is because duplicate observation.
>My question is can I force the sas only create one Column,no matter
>whether the dataset has duplicated obs like this"
>
> Obs id1 id2 _NAME_ COL1
> 1 1 2 num 3
> 2 2 3 num 4
> 3 2 3 num 5
>
>
>Thanks
|