Date: Thu, 14 Jul 2005 13:16:22 -0400
Reply-To: Jim Groeneveld <jim1stat@YAHOO.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jim Groeneveld <jim1stat@YAHOO.CO.UK>
Subject: Re: A question about proc transpose
Well, sure Smartie,
Because it's almost Friday, here is a circular solution:
data a;
input id1 id2 num;
datalines;
1 2 3
2 3 4
2 3 5
;
run;
proc print data=a;
TITLE "Dataset A (original)";
run;
proc transpose data=a out=b ;
by id1 id2;
var num;
run;
proc print data=b;
TITLE "Dataset B (intermediate)";
run;
PROC TRANSPOSE DATA=B (DROP=_NAME_) OUT=C (WHERE=(COL1 GT .z));
by id1 id2;
var Col1 Col2;
run;
proc print data=c;
TITLE "Dataset C (almost original again)";
run;
Of course it's not the longest one; I can invent much more complicated ones.
Regards - Jim [;-)
P.S. See http://www.sconsig.com/pictures_of_sasl/pres0015.html
and you'll see the origin of the above solution.
--
Y. (Jim) Groeneveld, MSc., Biostatistician, Vitatron b.v., NL
Jim.Groeneveld_AT_Vitatron.com (replace _AT_ by AT sign)
http://www.vitatron.com, http://home.hccnet.nl/jim.groeneveld
My computer always teaches me something new I thought I knew already.
[common disclaimer]
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