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 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 13 Mar 2000 17:52:57 -0500
Reply-To:     "Slagle, Paul" <Paul.Slagle@STATPROBE.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Slagle, Paul" <Paul.Slagle@STATPROBE.COM>
Subject:      Re: Longitudinal Tracking Help
Comments: To: SAS-L@LISTSERV.VT.EDU
Content-Type: text/plain; charset="iso-8859-1"

Ian,

I don't disagree with you or John's use of array's to transpose/normalize the data being received. I'll also admit to, at times, using an array when I want ultimate control and/or to "brute force" to a solution.

The reason for my asking the question is that I have found that the use of TRANSPOSE allows me to make my code somewhat more generalized for use across programs without having to create macros to do so. Specifically, when data is received that has month's (and years!) received across the page (and new months being added to the rightmost column), the TRANPOSE procedure allows a program to be developed once and to grow with the data. This is also why I thought initially for using TRANSPOSE with this question, as I imagined that as students progressed the need for increasing the evaluation would be necessary.

Thanks for your feedback on my nickles worth.

Paul Slagle

-----Original Message----- From: WHITLOI1 [mailto:WHITLOI1@WESTAT.COM] Sent: Monday, March 13, 2000 11:43 AM To: SAS-L@LISTSERV.VT.EDU Subject: Re: Longitudinal Tracking Help

Jim,

The following code indicates the general pattern for transposing multiple variables with multiple rows. I am inclined to use arrays because I find them clearer and more efficient. However the pattern to do what you want with TRANSPOSE is worth understanding.

data w ( keep = id /* unit identifier */ n /* seq identifier */ a b c d e /* variables */ ) ; array x (5) a b c d e ; t = 0 ; do id = 1 to 3 ; do n = 1 to 4 ; do j = 1 to 5 ; t + 1 ; x(j) = t ; end ; output ; end ; end ; run ;

/* transpose to one column + idetifiers */ proc transpose data = w out = t ; by id n ; /* using unit and seq identifiers */ run ;

/* incorporate seq identifiers in _name_ */ data t2 ; length _name_ $ 32 ; set t ; _name_ = trim(_name_) || "_" || left(put(n,3.)) ; run ;

/* transpose again by the unit identifier */ proc transpose data = t2 out = t3 ( drop = _name_ ) ; by id ; id _name_ ; var col1 ; run ;

Usually the is one or more variables in the unit identifier, but if not then just remove move the unit identifier in the above code and the last empty by-statement. In this case the result is one record.

Ian Whitlock <whitloi1@westat.com>

____________________Reply Separator____________________ Subject: Re: Longitudinal Tracking Help Author: Jim Groeneveld <J.Groeneveld@ITGROUPS.COM> Date: 3/13/2000 9:48 AM

Paul,

In your response to Ian (below) you're asking why not TRANSPOSE instead of much data step code. I'll try to explain my reason why. We receive data, repeated observations as well, as one observation per record (more different observations within the same record, but repetitions of the same observation in different records). The number of repetitions between cases (with multiple records) may differ. For specific analyses (some PROCs accept the multiple record structure) we need to restructure such data into a repeteated measurement style, i.e. all repetitions of one (or more) variables within a single record.

If it concerns a single Repeated Measurement (RM) variable PROC TRANSPOSE will do; if it concerns more than one, additional code is necessary, because PROC TRANSPOSE only rotates (a part of) the rectangular data matrix, making columns of rows and rows of columns, while I need making columns of rows, but not rows of columns.

Visually explained, suppose a rectangular data matrix containing RM variables looks like: 1 2 3 4 5 | | | | | | | | | | | | | | | | | | | | PROC TRANSPOSE would convert it into: 1- - - - 2- - - - 3- - - - 4- - - - 5- - - - but I need the following structure: 1- - - - 2- - - - 3- - - - 4- - - - 5- - - -

That is why I often do it without the use of PROC TRANSPOSE, but with the use of ARRAYs. Actually I often make use of a macro (that internally applies arrays), that does it for any number of RM variables at the same time.

Regards - Jim. -- Y. Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070 senior statistician, P.O. Box 1 fax. +31 412 407 080 head IT department 5350 AA BERGHEM IMRO TRAMARKO: a CRO J.Groeneveld@ITGroups.com the Netherlands in clinical research

My computer seems more ²°°°-compatible than I am myself.

> -----Original Message----- > From: Slagle, Paul [SMTP:Paul.Slagle@STATPROBE.COM] > Sent: Friday, March 10, 2000 8:32 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: Longitudinal Tracking Help > > Ian, > > I do have a question. Not only in this message but in others, I have > noticed a tendency of yours to amass a rather large amount of data step > code > to circumvent the use of the TRANSPOSE procedure. Is there a reason for > this or just style? > [.........]


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