Date: Fri, 19 Mar 2004 14:39:58 -0800
Reply-To: 0101 htns <htns0101@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: 0101 htns <htns0101@YAHOO.COM>
Subject: Re: transposing variable - re Howard's message
In-Reply-To: <200403192213.i2JMDfq30544@listserv.cc.uga.edu>
Content-Type: text/plain; charset=us-ascii
Hi Howard,
Sorry, it was my careless error due to using my old test data. You probably saw the data when I first posted it. I corrected it the second time. If you scroll down you will find the correct version of the test data. Good catch though. Have a great weekend!
Huong
Howard Schreier <Howard_Schreier@ITA.DOC.GOV> wrote:
If that solves the problem, then presumably the numeric portions of the
ignored character variables (VAR, X, ...) mean nothing. In other words, if
the explicit sequence for some ID level is
x='wk1'
x='wk2'
x='wk4'
you don't want to step over WK3 when loading the data into the new
structure. If otherwise, the problem is more complicated.
In any case, if the upper bound on the number of WKn variables is known,
I'd be tempted to forget about PROC TRANSPOSE and do it all in one DATA
step.
On Fri, 19 Mar 2004 13:39:52 -0800, 0101 htns wrote:
>Hi Paul,
>
>It's awsome! You solved my problem. Have a nice weekend!
>
>Huong
>
>"Choate, Paul@DDS"
wrote:
>
>
>data one;
>id='111'; var='wk1'; visit=1; output;
>id='111'; var='wk2'; visit=2; output;
>id='111'; var='wk3'; visit=1; output;
>id='111'; var='wk4'; visit=3; output;
>id='222'; x='wk1'; visit=1; output;
>id='222'; x='wk2'; visit=2; output;
>id='333'; x='wk1'; visit=2; output;
>run;
>
>proc transpose data = one
> out = two prefix = wk;
> by id;
>run;
>
>data two;
> set two;
> array num _numeric_;
> do over num;
> if num=. then num=0;
> end;
>
>proc print data =two;
>run;
>
>good luck
>
>Paul Choate
>DDS Data Extraction
>(916) 654-2160
>
>-----Original Message-----
>From: 0101 htns [mailto:htns0101@YAHOO.COM]
>Sent: Friday, March 19, 2004 9:12 AM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: transposing variable
>
>Hi all,
>
>anybody know a efficient way to fix the missing values. Thank you
>
>"Choate, Paul@DDS"
wrote:You'll need to fix the
missing values.
>
>data one;
>id='111'; var='wk1'; visit=1; output;
>id='111'; var='wk2'; visit=2; output;
>id='111'; var='wk3'; visit=1; output;
>id='111'; var='wk4'; visit=3; output;
>id='222'; var='wk1'; visit=1; output;
>id='222'; var='wk2'; visit=2; output;
>id='333'; var='wk1'; visit=2; output;
>run;
>
>proc transpose data=one out=two prefix=wk;
>by id;
>run;
>
>proc print data=two;
>run;
>
>hth
>
>Paul Choate
>DDS Data Extraction
>(916) 654-2160
>
>-----Original Message-----
>From: 0101 htns [mailto:htns0101@YAHOO.COM]
>Sent: Friday, March 19, 2004 8:44 AM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: transposing variable
>
>Dear SAS-Lers,
>
>I need to transpose the below data.
>
>data one;
>
>id='111';var='wk1';visit =1;output;
>
>id='111';var='wk2';visit =2; output;
>
>id='111';var='wk3';visit =1;output;
>
>id='111';var='wk4';visit=3; output;
>
>id='222'; x='wk1';visit=1; output;
>
>id='222'; x='wk2';visit=2; output;
>
>id='333'; x='wk1';visit=2; output;
>
>run;
>
>here's the expected result
>
>id _NAME_ wk1 wk2 wk3 wk4
>
>111 visit 1 2 1 3
>
>222 visit 1 2 0 0
>
>333 visit 2 3 0 0
>
>Thank you in advance.
>
>Huong
>
>
>
>
>Do you Yahoo!?
>Yahoo! Mail - More reliable, more storage, less spam
>
>Do you Yahoo!?
>Yahoo! Mail - More reliable, more storage, less spam
>
>Do you Yahoo!?
>Yahoo! Mail - More reliable, more storage, less spam
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
|