Hi guys, i've got the next dataset, and I would like to generate a dataset excluding the records with only baseline,
how can i do it?
subjid cpevent
10001 baseline
10001 w1
10001 w2
10001 w3
10001 w4
10002 baseline
10002 baseline
10003 baseline
10003 w1
10004 baseline
10004 w1
10004 w2
thanks.
V
just a subsetting IF
IF cpevent='baseline';
in the DATA step.
DC_Duke, is not right because with that condition I remove all the records with the baseline, and I dont want that,
I want the record that have (baseline and active treatment), excluding only the records with baseline and not active records after that.
Hi Michtka,
I can see clearly why Doc and Jagadishkatam were going that way. I choose not doing the same only hinted by your word 'with only baseline'. So maybe next time you could lay out the exact output you wanted on top of your input data set and rules, then it would be a lot easier for others to understand your issue dead on and you will get what you need more efficiently. You know, the last thing you want when asking a question is to let others having questions upon what exactly you are asking.
Regards,
Haikuo
Sorry, I'll be more clear next time...thanks.
Quick and dirty approach:
data have;
input (subjid cpevent) (:$);
cards;
10001 baseline
10001 w1
10001 w2
10001 w3
10001 w4
10002 baseline
10002 baseline
10003 baseline
10003 w1
10004 baseline
10004 w1
10004 w2
;
proc sql;
select * from have
group by subjid
having sum(cpevent ne 'baseline')>0;
quit;
Regards,
Haikuo
For a datastep approach, it seems to me 2X DOW could be the simplest:
data want;
flag=0;
do until (last.subjid);set have;by subjid;if cpevent ne 'baseline' then flag=1;end;
do until (last.subjid);set have;by subjid;if flag=1 then output;end;
run;
Regards,
Haikuo
Hi,
Please try the below code.
data exceptbaseline;
input subjid cpevent$;
if lowcase(cpevent)='baseline' then delete;
cards;
10001 baseline
10001 w1
10001 w2
10001 w3
10001 w4
10002 baseline
10002 baseline
10003 baseline
10003 w1
10004 baseline
10004 w1
10004 w2
;
run;
Jagadis...is not right, check my discussion with Duke.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.