BookmarkSubscribeRSS Feed
michtka
Fluorite | Level 6

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

8 REPLIES 8
Doc_Duke
Rhodochrosite | Level 12

just a subsetting IF

IF cpevent='baseline';

in the DATA step.

michtka
Fluorite | Level 6

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.


Haikuo
Onyx | Level 15

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

michtka
Fluorite | Level 6

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

Haikuo
Onyx | Level 15

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

Haikuo
Onyx | Level 15

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

Jagadishkatam
Amethyst | Level 16

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
michtka
Fluorite | Level 6


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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1119 views
  • 0 likes
  • 4 in conversation