From: Amar Mundankar on
Hi all,
The input dataset is as follows:
data sample;
input id a b c;
cards;
2 11 . .
2 . 44 .
2 . . 66
1 55 . .
1 . . 99
1 . 22 .
;
I want the output as
id a b c
2 11 44 66
1 55 22 99

The input dataset is not in sorted order by id . As my data is huge, i
can NOT sort the Sample dataset by Id.
In the output, i want as many number of records as many are Ids.
Also all the records related to one id are merged together to create a
single record for that particular id.
Please help.....

Thanks and Regards,
Amar Mundankar.
From: Barry Schwarz on
On Mon, 22 Mar 2010 02:49:52 -0700 (PDT), Amar Mundankar
<amarmundankar(a)gmail.com> wrote:

>Hi all,
>The input dataset is as follows:
>data sample;
> input id a b c;
> cards;
>2 11 . .
>2 . 44 .
>2 . . 66
>1 55 . .
>1 . . 99
>1 . 22 .
>;
>I want the output as
>id a b c
>2 11 44 66
>1 55 22 99
>
>The input dataset is not in sorted order by id . As my data is huge, i
>can NOT sort the Sample dataset by Id.
>In the output, i want as many number of records as many are Ids.
>Also all the records related to one id are merged together to create a
>single record for that particular id.

Try something like

data new (rename= saved_a=a saved_b=b saved_c=c);
retain saved_a-saved_c
set sample;
by notsorted id;
if first.id then
do;
saved_a = a;
saved_b = b;
saved_c = c;
end
else
do;
if saved_a = . then saved_a = a;
if saved_b = . then saved_b = b;
if saved_c = . then saved_c = c;
end;
if last.id then
output;
run;

--
Remove del for email