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 (December 2005, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 6 Dec 2005 19:54:09 -0500
Reply-To:   Wensui Liu <liuwensui@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Wensui Liu <liuwensui@GMAIL.COM>
Subject:   Re: from Variables to Observations
Comments:   To: lisiqi77@yahoo.com
In-Reply-To:   <1133914015.402403.284080@g14g2000cwa.googlegroups.com>
Content-Type:   text/plain; charset=ISO-8859-1

classic example to use array:

data one; input Date firm1 firm2; datalines; 1991 23 36 1992 26 22 ; run;

data two; set one; array x[2] firm1 - firm2; do i = 1 to dim(x); firm = vname(x[i]); price = x[i]; output; end; keep date firm price; run;

On 12/6/05, lisiqi77@yahoo.com <lisiqi77@yahoo.com> wrote: > > Hey, > > I have a dataset like this: > Date firm1 firm2 > 1991 23 36 > 1992 26 22 > > And I want to transform it to a dataset like the following: > > Date firm price > 1991 firm1 23 > 1991 firm2 36 > 1992 firm1 26 > 1992 firm2 22 > > I tried something like "keep" and "output" for each firm and then > "merge". But the problem is if I have 1,000 firms like this, it is too > much work. > > Please help if you have better ideas. Thanks a lot. > > Tracy >

-- WenSui Liu (http://statcompute.blogspot.com) Senior Decision Support Analyst Health Policy and Clinical Effectiveness Cincinnati Children Hospital Medical Center


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