Help using Base SAS procedures

baseline excluding records

Reply
Super Contributor
Posts: 301

baseline excluding records

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

Trusted Advisor
Posts: 2,113

Re: baseline excluding records

just a subsetting IF

IF cpevent='baseline';

in the DATA step.

Super Contributor
Posts: 301

Re: baseline excluding records

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.


Respected Advisor
Posts: 3,124

Re: baseline excluding records

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

Super Contributor
Posts: 301

Re: baseline excluding records

Sorry, I'll be more clear next time...thanks.

Respected Advisor
Posts: 3,124

Re: baseline excluding records

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

Respected Advisor
Posts: 3,124

Re: baseline excluding records

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

Trusted Advisor
Posts: 1,129

Re: baseline excluding records

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;

Thanks,
Jag
Super Contributor
Posts: 301

Re: baseline excluding records


Jagadis...is not right, check my discussion with Duke.

Ask a Question
Discussion stats
  • 8 replies
  • 295 views
  • 0 likes
  • 4 in conversation