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 (October 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 6 Oct 2008 15:37:21 -0400
Reply-To:     Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Subject:      Re: Multiple observations into multiple variables
In-Reply-To:  <200810061751.m96Al9Wt008886@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

On Mon, Oct 6, 2008 at 1:51 PM, Joseph Cormier <jcormier@brconline.com>wrote:

> I have a dataset that looks like this: Each person has multiple injuries... > > Year Person Injury Type > 2005 1 1 A > 2005 1 2 A > 2005 1 3 B > 2005 1 4 B > 2005 2 1 D > 2005 2 2 D > 2005 2 3 E > 2005 2 4 F > 2005 2 5 A > 2004 1 1 B > 2004 1 2 C > 2004 1 3 D > > I would like to create multiple variables for a single person so that the > different injuries are aligned in a single observation like this: > > Year Person Injury Injury 1 Injury 2 Injury 3 > 2005 1 1 A 0 0 > 2005 1 2 0 A 0 > 2005 1 3 0 0 B > 2005 1 4 0 0 0 > 2005 2 1 D 0 0 > 2005 2 2 0 D 0 > 2005 2 3 0 0 E > 2005 2 4 0 0 0 > 2005 2 5 0 0 0 > 2004 1 1 B 0 0 > 2004 1 2 0 C 0 > 2004 1 3 0 0 D > > Any help would be greatly appreciated, thanks. > > Joe >

Without Proc Transpose, it can be done too. The only requirement is to declare the array

array inj $1. inj_1 - inj_5;

with inj_1 to inj_5 to match the maximum number of injuries within a PERSON.

data need; do until (last.person); set have; by person notsorted; array inj $1. inj_1 - inj_5; inj[injury] = type; output; inj[injury] = ' '; end; drop injury type; run;

Muthia Kachirayan


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