Prev: Sustenance Lead - CA - 12 months Contract
Next: 10% off "Power User's Guide to SAS Programming" from Lulu.com until July 31
From: Reeza on 15 Jul 2010 15:38 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 15 Jul 2010 16:09
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 |