01-30-2016 05:42 PM - edited 02-01-2016 11:39 AM
I want to transofrm data that looks like as below:
and has followingfields :--> patid, date on which a medical team was added/removed, type of team , and action
The output that i need shoud be in this way:so for each date i have the team in one row and for missing dates i can populate
them as below...what is the most efficent way to do this in sas base sas ??ANy help will behighly appreciated...
1111 31-jan surgical obgyn
01-30-2016 07:06 PM - edited 01-30-2016 08:26 PM
You posted your same question THREE times in THREE Community !!!!! Why?
One possible Solution:
data want; set have; by patid date; array Team_ $; retain Team_ arrindex; if first.patid then do;arrindex=0; call missing (of Team_[*]);end; if trim(action) eq "added" then do; arrindex = arrindex+1; Team_[arrindex]=team; end; else if trim(action) eq "removed" and arrindex ~= 0 then do; Do i=1 to dim(Team_) by 1; if Team_[i]=team then do; do j=i to arrindex-1; Team_[j]=Team_[j+1]; end; Team_[j]=""; arrindex=arrindex-1; leave; end; end; end; else return; drop i j arrindex; run;
01-31-2016 06:35 PM
I am Sorry it got posted 3 times by mistake as I wasn't sure which category is right to post in. Will avoid this duplicate submission in future. Thanks for the innovative solution and bringing this up.
02-01-2016 10:29 AM - edited 02-01-2016 01:35 PM
The dates are not getting populated well in output
for missing dates , i want to populate them based on info from the previous non missing row as in output..
02-01-2016 01:34 PM - edited 02-01-2016 01:34 PM
Its a partial solution as dates are not getting populated where sequence missing but I find it very helpful to address problem using your approach..