InterviewSolution
Saved Bookmarks
| 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
|
|||||||||||||||||||||||||||||||||||||||||||||||||