SAS® and R

Best of Both Worlds

Check consistency in VISITNUM/VISIT in your SDTM domains

leave a comment »

One of the requirements during CDISC SDTM data validation is VISITNUM/VISIT pair in findings domains doesn’t match TV domain data. Here is an easy way to find out how visit is defined in all findings domain.

/* Select a list of SDTM domains that use VISITNUM/VISIT */
proc sql;
 select distinct(memname) into :gdmlist
 separated by '*'
 from   sashelp.vcolumn
 where  upcase(libname)="GDMDATA" and upcase(name)="VISIT";
quit;
 
%macro check;
  %let i = 1 ;
 
  %do %while(%scan(&gdmlist,&i,*) ^= %str( )) ;
    %let indsn = %scan(&gdmlist,&i,*) ;
    title "gdmdata.&indsn";
    proc freq data=gdmdata.&indsn noprint;
      tables visitnum*visit/list missing out=test(where=(visitnum>.z and ^missing(visit)));
    run;
   
    proc transpose data=test out=vtest prefix=v;
      var visit;
      id  visitnum;
    run;
    
    data out;
      set vtest;
      length source $ 2;
      
      source=%upcase("&indsn");
    run;
    
    proc append base=final data=out force;
    run;
    
    %let i = %eval(&i + 1 ) ;
  %end ;
%mend check;
 
%check;

And the print out of the data shows how VISITNUM/VISIT are defined, and it is easy to identify problems. Actually TV domain is inconsistent with all the rest of the findings domains.

Obs    SOURCE      V4         V5         V6         V7         V8         V9         V10          V11          V888

  1      DA      Visit 4    Visit 5    Visit 6    Visit 7    Visit 8    Visit 9    Visit 10    Visit 11a    Unscheduled
  2      EG      Visit 4    Visit 5    Visit 6               Visit 8                           Visit 11a    Unscheduled
  3      EX      Visit 4    Visit 5    Visit 6    Visit 7    Visit 8    Visit 9    Visit 10    Visit 11a    Unschedule 
  4      HO                 Visit 5    Visit 6    Visit 7    Visit 8               Visit 10    Visit 11a    Unscheduled
  5      IE                                                                                                            
  6      LB      Visit 4               Visit 6               Visit 8                           Visit 11a    Unscheduled
  7      QS      Visit 4               Visit 6    Visit 7    Visit 8    Visit 9    Visit 10    Visit 11a    Unscheduled
  8      TV      Visit 4    Visit 5    Visit 6    Visit 7    Visit 8    Visit 9    Visit 10    Visit 11                
  9      VS      Visit 4    Visit 5    Visit 6    Visit 7    Visit 8    Visit 9    Visit 10    Visit 11a    Unscheduled
 10      ZU                 Visit 5    Visit 6    Visit 7    Visit 8    Visit 9    Visit 10    Visit 11a    Unscheduled
Advertisements

Written by sasandr

March 28, 2014 at 4:06 pm

Posted in Data, SAS

Tagged with , , ,

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: