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 (November 2006, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 3 Nov 2006 15:08:03 -0500
Reply-To:   "data _null_;" <datanull@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "data _null_;" <datanull@GMAIL.COM>
Subject:   Re: beginner array question
Comments:   To: Lu Liu <lliugy84@yahoo.com>
In-Reply-To:   <20061103195722.84342.qmail@web31008.mail.mud.yahoo.com>
Content-Type:   text/plain; charset=ISO-8859-1; format=flowed

INDEXC could be applied to this problem. Consider this example usage of indexc.

1067 data _null_; 1068 do product = 'A','B','C'; 1069 i = indexC('ABC',product); 1070 put (_all_) (=); 1071 end; 1072 run;

product=A i=1 product=B i=2 product=C i=3

On 11/3/06, Lu Liu <lliugy84@yahoo.com> wrote: > Hello, > > I am learning array statement and want to transform dataset test to dataset test2. > > dataset - Test > ID Product Price > 1 A 10 > > 1 B 50 > > 1 C 25 > > 2 A 20 > > 2 B 30 > > 2 C 30 > > > > dataset - test2 > > ID A B C > 1 10 50 25 > 2 20 30 30 > > I used the following code, but it is not completely working. I think it has to be with product variable is character variable not numerical variable, but I am sure how to fix it. > > data test2; > > set test; > > by id; > > array prod(3) A B C ; > > retain A B C; > > prod(product) = price; > > if last.id then output; > > drop product price; > > run; > > > Any help will be greatly appreciated. > > Thank you, > Lu >


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