1.

Find the number of patients with daig code (D45) and calculate the age of each patient between 01st Jan 2018 to 31 March 2019 from the table given below.

Answer»

SUPPOSE we have the above clinical table in the form of SAS Dataset in lib – ‘mylib’. Considering the fact, the following code will give the desired results. 

Data Clinical_Analysis; Set mylib.clinical; If '01JAN2018'D <= Data <= '31MAR2019'D ; array DIAG(*) $diag1 - diag5; do i=1 to 5; if diag(i) in ('D45') then f_diag =1; END; run; proc sort data = Clinical_Analysis; by IDS date; run; Data diag_pat (keep = IDs YOB Date f_diag first_date diag age); set Clinical_Analysis; by Ids; format first_date date9.; retain diag first_date age; if first.Ids then do; diag=0; first_date =date; age =0; end; age = Year(first_date) - yob; if f_diag =1 then diag=1; if last.Ids; run; Proc freq data = diag_pat; title "All required COUNTS"; tables diag age/missing list; run;

output: 

Dataset of the code – Table: diag_pat

OBS
IDs
YOB
Date
f_diag
first_date
diag
Age
1
100
2-Mar-86
8-Mar-18
1
2-Mar-18
1
32
4
101
5-Jan-80
18-Apr-18
18-Jan-18
138
9
102
4-Jan-85
15-Feb-19
118-Jan-17
134
14
103
16-Jan-90
17-Mar-18
115-Feb-18
128
18
104
25-Jan-92
18-Apr-18
127-Feb-18
126


Discussion

No Comment Found