From: Reeza on
Hi,

I have string data like this:

A
B
C
D

and I want the results to look like this:
var combined
A A
B AB
C ABC
D ABCD

I tried a simple retain with cat and || in SAS but it didn't seem to
work.

ie

data want;
set have;
retain combined;
combined=cat(combined, var);
run;

Any help appreciated.

Thanks,
Reeza
From: Carl Kaufmann on
On 2010-07-15 15:38, Reeza wrote:
> Hi,
>
> I have string data like this:
>
> A
> B
> C
> D
>
> and I want the results to look like this:
> var combined
> A A
> B AB
> C ABC
> D ABCD
>
> I tried a simple retain with cat and || in SAS but it didn't seem to
> work.
>
> ie
>
> data want;
> set have;
> retain combined;
> combined=cat(combined, var);
> run;
>
> Any help appreciated.
>
> Thanks,
> Reeza

You need a LENGTH statement to make sure the COMBINED variable can
hold the longest string encountered, e.g. LENGTH COMBINED $ 200

Carl