BookmarkSubscribeRSS Feed
rakeshvvv
Quartz | Level 8

I have dataeset with varaibles ID, VISIT, DAYS(Number of days). Visit can have values 'Screening' AND 'C1D1'.

We have to write edit check:

The Visit C1D1 has to be within 3 days (unless also screening is within 3 days)...if this is not satisfied..we have to output the discrepancies...

Thanks

Rakesh

3 REPLIES 3
Steelers_In_DC
Barite | Level 11

can you provide an example of the data you have?

Steelers_In_DC
Barite | Level 11

This might work for you, it depends on what the data looks like, a proc sql; sum group by could work too:

data have;

infile cards dsd;

length visit $10.;

input id $ visit $ days;

cards;

001,Screening,2

001,C1D1,3

002,Screening,4

002,C1D1,3

003,Screening,5

003,C1D1,4

;

run;

proc sort data=have;by id descending visit;

data want;

set have;

by id;

screen_days = lag(days);

if not first.id then do;

    if screen_days > 3 then do;

        if days > 3 then output;

    end;

end;

run;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Without test data, this is not tested, but something like:

proc sql;

     create table OUTLIERS as

     select     COALESCE(A.ID,B.ID) as ID,

                    A.DAYS as BASE,

                   B.DAYS as COMPARE,

                    case     when A.DAYS is null then "Base Missing"

                                 when B.DAYS is null then "Comp Missing"

                                 when A.DAYS is not null and B.DAYS is not null and B.DAYS - A.DAYS not between 0 and 3  then "Outside window" end as RESULT

     from       (select * from HAVE where VISIT="SCREENING") A

     full join   (select * from HAVE where VISIT="C1D1") B

     on          A.ID=B.ID;

quit;

You can filter on result.  note you do need to check if one or the other is missing.

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
  • 3 replies
  • 722 views
  • 3 likes
  • 3 in conversation