LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (December 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 3 Dec 2008 16:56:27 -0500
Reply-To:     Akshaya Nathilvar <akshaya.nathilvar@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Akshaya Nathilvar <akshaya.nathilvar@GMAIL.COM>
Subject:      Re: Proc Transpose - long to wide
Comments: To: sas 9 bi user <sas9bi@gmail.com>
In-Reply-To:  <af7d406c0812031346k70472f47k577fb07d79f99d01@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Proc transpose and rename option will help: Proc transpose data=have out=want(drop=_name_ rename=(col1= col2= col3=)); by id seq; var response; Run;

Akshaya

On Wed, Dec 3, 2008 at 4:46 PM, sas 9 bi user <sas9bi@gmail.com> wrote:

> /* > Friends, > > I have the below data, I need to reshape it and have spent far too long > trying and thought you all could assist. > > The data is survey data, so a person can take multiple surveys during one > phone call. Each person is given a unique person ID and then a sequence > number. There is also a survey code to differentiate the survey and then > their responses (string values). > > This is what the data looks like in the 'Have' dataset below. In my 'Want' > dataset that is how I want it to look when converted to wide. Some > questions can have null responses which is reflected in my last record in > my > have below. I need to allow for null responses. > > Thanks in advance for your suggestions! > */ > data have; > length type_of_question $10 response $20; > input id seq question_number type_of_question $ response $; > cards; > 100 1 1 Health 3 > 100 1 2 Health Good > 100 1 1 Family 2 > 100 1 2 Family Great > 100 2 1 Health 1 > 100 2 2 Health Bad > 100 2 1 Family 9 > 100 2 2 Family > ; > run; > data want; > length Health_response_1 $20 Health_response_2 $20 Family_response_1 $20 > Family_response_2 $20; > input id seq Health_response_1 Health_response_2 Family_response_1 > Family_response_2; > cards; > 100 1 3 Good 2 Great > 100 2 1 Bad 9 > ; > run; >


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