forked from caojiguo/FDAworkshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.sas
More file actions
97 lines (79 loc) · 1.96 KB
/
data.sas
File metadata and controls
97 lines (79 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
options sasautos=("C:\review\checklist");
libname sdtm "C:\review\sdtm";
%let fdf_file=C:\review\sdtm\acrf.fdf;
data afdf;
infile "&fdf_file" print lrecl=2000 pad missover;
input text $char2000.;
run;
data match(keep=anno page_num); set afdf;
pos1=prxmatch("/\/Contents\(/", text);
pos2=prxmatch("/\)\/Creation/", text);
anno=substrn(text, pos1+10, pos2-pos1-10);
pos3=prxmatch("/\/Page /", text);
pos4=prxmatch("/\/RC/", text);
page_num=substrn(text, pos3+1, pos4-pos3-1);
if anno>' ';
run;
data match; set match;
retain pat1 pat2;
if _N_=1 then do;
pat1=prxparse("/\w+\.\w+/");
pat2=prxparse("/\w+\.QNAM=\w+/");
end;
call prxsubstr(pat2, anno, start, length);
if start gt 0 then do;
match0 = substrn(anno,start,length );
end;
start=1;
stop=length(anno);
call prxnext(pat1, start, stop, anno, position, length);
array match[3] $20.;
do i = 1 to 3 while (position gt 0);
match[i] = substr(anno,position,length);
call prxnext(pat1,start,stop,anno,position,length);
end;
run;
proc sort data=match out=chk(keep=match0) nodupkey; by match0;
where match0>' ';
run;
data chk; set chk;
mydomain=scan(match0, 1, '.');
myvar=scan(match0,2,'=');
run;
%list_files(path=%str(%sysfunc(pathname(sdtm))));
run;
data f1; set f1;
name=scan(names,1,'.');
if upcase(substr(name,1,4))='SUPP';
run;
data _null_;
set f1 end=eof;
i+1;
call symput(compress('name'||i), trim(left(name)));
if eof then call symput('tot', trim(left(_n_)));
run;
%macro getit;
%do k=1 %to &tot;
proc sql;
create table tt&k as
select distinct qnam as myvar, qlabel as mylabel from sdtm.&&name&k;
data tt&k; set tt&k;
mydomain=upcase("&&name&k");
run;
data final;
set %if &k=1 %then %do; tt1 %end; %else %do; final tt&k %end;;
run;
%end;
%mend;
%getit;
** do the comparison;
proc sort data=final; by mydomain myvar;
proc sort data=chk; by mydomain myvar;
data comp2(drop=mylabel);
merge final(in=a) chk(in=b);
by mydomain myvar;
if b and not a;
run;
proc print data=comp2;
title "QNAM in the aCRF but not in data";
run;