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
can you provide an example of the data you have?
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;
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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.