LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 19 Mar 2004 17:13:41 -0500
Reply-To:     Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject:      Re: transposing variable

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 <htns0101@YAHOO.COM> wrote:

>Hi Paul, > >It's awsome! You solved my problem. Have a nice weekend! > >Huong > >"Choate, Paul@DDS" <pchoate@DDS.CA.GOV> 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" <pchoate@DDS.CA.GOV> 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


Back to: Top of message | Previous page | Main SAS-L page