SAS® and R

Best of Both Worlds

Check controlled SDTM terminology

leave a comment »

%macro chk_ct (indsn=, var=, codelist=);

%if &codelist=%str() %then %let codelist=%upcase(&var);

proc freq data=&indsn noprint;
tables &var / missing out=&var;

proc sql noprint;
create table check as
select &var, b.cdisc_submission_value, b.codelist
from   &var left join metadata.sdtm_ct_20150626(where=(codelist="%upcase(&codelist)")) as b
on     &var=b.cdisc_submission_value;

data final;
set check;
length flag $ 3;
if  &var^=cdisc_submission_value then flag='No';
else if cmiss(&var, cdisc_submission_value)=0 then flag='Yes';

proc sql noprint;
select count(*) into: totcnt from final

%if &totcnt=0 %then %do;
data final;
xx='No Data'; output;
set final; output;

title "Check if variable values match CDISC submission values";
proc report data=final nowd missing headline headskip spacing=2 split='@' formchar(2)='_';
column flag codelist &var cdisc_submission_value;
define flag     / order width=3 ' ';
define codelist / order "Codelist@(&codelist)" width=20;
define &var     /  width=40 flow "Variable@(%upcase(&var))";
define cdisc_submission_value / width=40 flow "CDISC@Submission@Value";

break after flag / skip;
%if &totcnt=0 %then %do;
compute after;
line @1 ' ';
line @1 ' ';
line @10 'Variable values matched CDISC submission values';

%mend chk_ct;

Written by sasandr

March 10, 2016 at 11:54 am

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: