|
On May 13, 11:40 am, need_sas_h...@YAHOO.COM (Tom Smith) wrote:
> I had posted this problem earlier. But guesss I could not make it clear in
> my last post. So I think I cofused those who tried to help me out. So I am
> trying to make it clear below and more simple:
>
> I have a following dataset having variables:SUB, HR as bellow:
>
> SUB HR
> 1003 post
> 1003 pre
> 1004 post
> 1004 post
> 1004 Pre
> 1005 post
> 1005 pre
> 1005 failed
> 1005 never tried
>
> Need to create another dataset from it which will be by the variable SUB
> as below(means it will have only one observation for each SUB variable's
> value and all the values for HR for that perticular value of SUB will be
> in the same record one after another. Plz do not use Proc Report. I need a
> dataset.
> SUB HR
> 1003 post /
> pre
> 1004 post /post /
> Pre
> 1005 post / pre /
> failed /
> never tried
Hi Tom
you can try like this:
data a;
input sub hr$;
cards;
1003 post
1003 pre
1004 post
1004 post
1004 Pre
1005 post
1005 pre
1005 failed
1005 never tried
;
proc print;run;
data b;
set a;
by sub;
retain hour;
if first.sub then hour=cats(hr);
else hour=cats(hour)||'/'||cats(hr);
if last.sub then output;
run;
Best regards
Yuewei
|