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:         Wed, 7 Dec 2005 07:44:34 -0600
Reply-To:     Jiann-Shiun Huang <Jiann-Shiun.Huang@AMERUS.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jiann-Shiun Huang <Jiann-Shiun.Huang@AMERUS.COM>
Subject:      Re: from Variables to Observations
Comments: To: lisiqi77@YAHOO.COM
Content-Type: text/plain; charset=US-ASCII


I tested the following and it worked.

data one; input year firm1 firm2; cards; 1991 23 36 1992 26 22 ; data two(keep=year firmname price); set one; array firm(2) firm1-firm2; do i = lbound(firm) to hbound(firm); firmname = 'firm' || trim(left(i)); price = firm(i); output; end; proc print nobos; run;

J S Huang

>>> <lisiqi77@YAHOO.COM> 12/6/2005 6:06:55 PM >>> 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.


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