|
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
|