04-29-2015 10:22 AM
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...
04-29-2015 11:27 AM
This might work for you, it depends on what the data looks like, a proc sql; sum group by could work too:
infile cards dsd;
length visit $10.;
input id $ visit $ days;
proc sort data=have;by id descending visit;
screen_days = lag(days);
if not first.id then do;
if screen_days > 3 then do;
if days > 3 then output;
04-29-2015 11:45 AM
Without test data, this is not tested, but something like:
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
You can filter on result. note you do need to check if one or the other is missing.