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 (August 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 28 Aug 2007 14:11:07 -0500
Reply-To:   Mary <mlhoward@avalon.net>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Mary <mlhoward@AVALON.NET>
Subject:   Re: Transforming multiple records to one record
Comments:   To: Nat <venkateshnt@GMAIL.COM>
Content-Type:   text/plain; charset="utf-8"

Nat,

Is there the same number of lines per ID? If so, you might be able just to specify the number of lines and read the appropriate variable from each line, like this below (code below is not tested).

ata sam1; infile cards missover n=3; input #1 @1 id $3. @5 a1 $1. #2 @7 a2 $1. #3 @9 a3 $1.; cards; 101 1 . . . * 101 . 2 . . * 101 . . 3 . * ; run;

proc print; run;

-Mary ----- Original Message ----- From: Nat To: SAS-L@LISTSERV.UGA.EDU Sent: Tuesday, August 28, 2007 1:27 PM Subject: Transforming multiple records to one record

Hi everyone,

I have a dataset with multiple records for same ID like this:

data sam1; input id a1 a2 a3 a4 a5 $ a6 $; cards; 101 1 . . . * 101 . 2 . . * 101 . . 3 . * 101 . . . 4 * 102 1 . 3 . * . 102 . 2 . 4 . ;

I would like to have my output dataset to look like this: one record per id;

id a1 a2 a3 a4 a5 a6 =================== 101 1 2 3 4 * 102 1 2 3 4 *

I tried to use both array and proc transpose to get the output, but the variables are different data types (Character & Numeric), it gives me an error.

Please input your suggestions. Thanks for your help.

Regards! Nat


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