Friday, September 4, 2009

SAS: How to Retian a Char Variable in SAS

data temp;
infile cards;
input hosp $3.;
cards;
abc
opq
xyz
;
run;
data tttt;
retain hosplist;
retain cnt;

length hosplist $200;

set temp;
if _n_ = 1 then hosplist = hosp;
*else hosplist = hosplist hosp;
else hosplist = trim(hosplist) hosp;


if _n_ = 1 then cnt = 1;
else cnt + 1;

put _all_;
run;