Datasets1 :
Site_number | Subject_ID | Date_of_birth | Gender | Visit_name | Sample_not_taken | Sample_date | Sample_time | CATGY | Laboratory_test | Clin_sign | Specify_clin_signf | Was_repeat_sample_taken |
10 | 10-006 | 25-Jan-91 | F | SCREENING | 4-Mar-22 | 17:38:00 | Hematology | Hematology -1 | No | No | ||
10 | 10-006 | 25-Jan-91 | F | SCREENING | 4-Mar-22 | 17:38:00 | Serum chemistry | Serum chemistry -1 | No | No | ||
10 | 10-006 | 25-Jan-91 | F | SCREENING | 4-Mar-22 | 17:38:00 | Serum chemistry | Thyroid assessment -1 | No | No | ||
10 | 10-006 | 25-Jan-91 | F | D -1 | 31-Mar-22 | 13:24:00 | Hematology | Hematology -1 | No | No | ||
10 | 10-006 | 25-Jan-91 | F | D -1 | 31-Mar-22 | 13:24:00 | Serum chemistry | Serum chemistry -1 | No | No | ||
10 | 10-006 | 25-Jan-91 | F | D -1 | 31-Mar-22 | 13:24:00 | Serum chemistry | Thyroid assessment -1 | No | No | ||
10 | 10-006 | 25-Jan-91 | F | D 1 POST 1HR | 1-Apr-22 | 11:19:00 | Hematology | Hematology -1 | No | Yes | ||
10 | 10-006 | 25-Jan-91 | F | D 1 POST 1HR | 1-Apr-22 | 11:19:00 | Serum chemistry | Serum chemistry -1 | No | No | ||
10 | 10-006 | 25-Jan-91 | F | D 1 POST 1HR | 1-Apr-22 | 11:19:00 | Serum chemistry | Thyroid assessment -1 | No | No | ||
10 | 10-006 | 25-Jan-91 | F | D 7 EOS | 7-Apr-22 | 8:40:00 | Hematology | Hematology -1 | No | No | ||
10 | 10-006 | 25-Jan-91 | F | D 7 EOS | 7-Apr-22 | 8:40:00 | Serum chemistry | Serum chemistry -1 | No | No | ||
10 | 10-006 | 25-Jan-91 | F | D 7 EOS | 7-Apr-22 | 8:40:00 | Serum chemistry | Thyroid assessment -1 | No | No | ||
10 | 10-007 | 15-Jan-78 | M | SCREENING | 9-Mar-22 | 14:45:00 | Hematology | Hematology -1 | No | No | ||
10 | 10-007 | 15-Jan-78 | M | SCREENING | 9-Mar-22 | 14:45:00 | Serum chemistry | Serum chemistry -1 | No | No | ||
10 | 10-007 | 15-Jan-78 | M | SCREENING | 9-Mar-22 | 14:45:00 | Serum chemistry | Thyroid assessment -1 | No | No | ||
10 | 10-007 | 15-Jan-78 | M | D -1 | 31-Mar-22 | 13:20:00 | Hematology | Hematology -1 | No | No | ||
10 | 10-007 | 15-Jan-78 | M | D -1 | 31-Mar-22 | 13:20:00 | Serum chemistry | Serum chemistry -1 | No | No | ||
10 | 10-007 | 15-Jan-78 | M | D -1 | 31-Mar-22 | 13:20:00 | Serum chemistry | Thyroid assessment -1 | No | No | ||
10 | 10-007 | 15-Jan-78 | M | D 1 POST 1HR | 1-Apr-22 | 12:22:00 | Hematology | Hematology -1 | No | No | ||
10 | 10-007 | 15-Jan-78 | M | D 1 POST 1HR | 1-Apr-22 | 12:22:00 | Serum chemistry | Serum chemistry -1 | No | No | ||
10 | 10-007 | 15-Jan-78 | M | D 1 POST 1HR | 1-Apr-22 | 12:22:00 | Serum chemistry | Thyroid assessment -1 | No | No | ||
10 | 10-007 | 15-Jan-78 | M | D 7 EOS | 7-Apr-22 | 10:00:00 | Hematology | Hematology -1 | No | No | ||
10 | 10-007 | 15-Jan-78 | M | D 7 EOS | 7-Apr-22 | 10:00:00 | Serum chemistry | Serum chemistry -1 | No | No | ||
10 | 10-007 | 15-Jan-78 | M | D 7 EOS | 7-Apr-22 | 10:00:00 | Serum chemistry | Thyroid assessment -1 | No | No | ||
10 | 10-014 | 19-Jul-97 | F | SCREENING | 5-Apr-22 | 17:09:00 | Hematology | Hematology -1 | No | No | ||
10 | 10-014 | 19-Jul-97 | F | SCREENING | 5-Apr-22 | 17:09:00 | Serum chemistry | Serum chemistry -1 | No | No | ||
10 | 10-014 | 19-Jul-97 | F | SCREENING | 5-Apr-22 | 17:09:00 | Serum chemistry | Thyroid assessment -1 | No | No | ||
10 | 10-014 | 19-Jul-97 | F | D -1 | 13-Apr-22 | 13:31:00 | Hematology | Hematology -1 | No | No | ||
10 | 10-014 | 19-Jul-97 | F | D -1 | 13-Apr-22 | 13:31:00 | Serum chemistry | Serum chemistry -1 | No | No | ||
10 | 10-014 | 19-Jul-97 | F | D -1 | 13-Apr-22 | 13:31:00 | Serum chemistry | Thyroid assessment -1 | No | No | ||
10 | 10-014 | 19-Jul-97 | F | D 1 POST 1HR | 14-Apr-22 | 10:45:00 | Hematology | Hematology -1 | No | No | ||
10 | 10-014 | 19-Jul-97 | F | D 1 POST 1HR | 14-Apr-22 | 10:45:00 | Serum chemistry | Serum chemistry -1 | No | No | ||
10 | 10-014 | 19-Jul-97 | F | D 1 POST 1HR | 14-Apr-22 | 10:45:00 | Serum chemistry | Thyroid assessment -1 | No | No | ||
10 | 10-014 | 19-Jul-97 | F | D 7 EOS | 21-Apr-22 | 15:05:00 | Hematology | Hematology -1 | No | No | ||
10 | 10-014 | 19-Jul-97 | F | D 7 EOS | 21-Apr-22 | 15:05:00 | Serum chemistry | Serum chemistry -1 | No | No | ||
10 | 10-014 | 19-Jul-97 | F | D 7 EOS | 21-Apr-22 | 15:05:00 | Serum chemistry | Thyroid assessment -1 | No | No |
Data set 2 :
Vendor_Site_number | Subject_ID | Vendor_Date_of_birth | Vendor_Gender | Vendor_Visit_name | Vendor_Vis_Num | Vendor_Sample_date | Vendor_Sample_time | Vendor_CATGY | CAT | Vendor_Clin_sign |
10 | 10-006 | 25-Jan-91 | F | SCREENING | 1 | 4-Mar-22 | 17:38:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-006 | 25-Jan-91 | F | SCREENING | 1 | 4-Mar-22 | 17:38:00 | Hematology | HAEMATOLOGY | N/A |
10 | 10-006 | 25-Jan-91 | F | D -1 | 2 | 31-Mar-22 | 13:24:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-006 | 25-Jan-91 | F | D -1 | 2 | 31-Mar-22 | 13:24:00 | Hematology | HAEMATOLOGY | N/A |
10 | 10-006 | 25-Jan-91 | F | D 1 POST 1HR | 3 | 1-Apr-22 | 11:19:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-006 | 25-Jan-91 | F | D 1 POST 1HR | 3 | 1-Apr-22 | 11:19:00 | Hematology | HAEMATOLOGY | N/A |
10 | 10-006 | 25-Jan-91 | F | D 2 | 4 | 2-Apr-22 | 10:22:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-006 | 25-Jan-91 | F | D 2 | 4 | 2-Apr-22 | 10:22:00 | Hematology | HAEMATOLOGY | N/A |
10 | 10-006 | 25-Jan-91 | F | D 7 EOS | 5 | 7-Apr-22 | 8:40:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-006 | 25-Jan-91 | F | D 7 EOS | 5 | 7-Apr-22 | 8:40:00 | Hematology | HAEMATOLOGY | N/A |
10 | 10-007 | 15-Jan-78 | M | SCREENING | 1 | 9-Mar-22 | 14:45:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-007 | 15-Jan-78 | M | SCREENING | 1 | 9-Mar-22 | 14:45:00 | Hematology | HAEMATOLOGY | N/A |
10 | 10-007 | 15-Jan-78 | M | D -1 | 2 | 31-Mar-22 | 13:20:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-007 | 15-Jan-78 | M | D -1 | 2 | 31-Mar-22 | 13:20:00 | Hematology | HAEMATOLOGY | N/A |
10 | 10-007 | 15-Jan-78 | M | D 1 POST 1HR | 3 | 1-Apr-22 | 12:22:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-007 | 15-Jan-78 | M | D 1 POST 1HR | 3 | 1-Apr-22 | 12:22:00 | Hematology | HAEMATOLOGY | N/A |
10 | 10-007 | 15-Jan-78 | M | D 2 | 4 | 2-Apr-22 | 11:22:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-007 | 15-Jan-78 | M | D 2 | 4 | 2-Apr-22 | 11:22:00 | Hematology | HAEMATOLOGY | N/A |
10 | 10-007 | 15-Jan-78 | M | D 7 EOS | 5 | 7-Apr-22 | 10:00:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-007 | 15-Jan-78 | M | D 7 EOS | 5 | 7-Apr-22 | 10:00:00 | Hematology | HAEMATOLOGY | N/A |
10 | 10-014 | 19-Jul-97 | F | SCREENING | 1 | 5-Apr-22 | 17:09:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-014 | 19-Jul-97 | F | SCREENING | 1 | 5-Apr-22 | 17:09:00 | Hematology | HAEMATOLOGY | N/A |
10 | 10-014 | 19-Jul-97 | F | D -1 | 2 | 13-Apr-22 | 13:31:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-014 | 19-Jul-97 | F | D -1 | 2 | 13-Apr-22 | 13:31:00 | Hematology | HAEMATOLOGY | N/A |
10 | 10-014 | 19-Jul-97 | F | D 1 POST 1HR | 3 | 14-Apr-22 | 10:45:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-014 | 19-Jul-97 | F | D 1 POST 1HR | 3 | 14-Apr-22 | 10:45:00 | Hematology | HAEMATOLOGY | N/A |
10 | 10-014 | 19-Jul-97 | F | D 2 | 4 | 15-Apr-22 | 9:45:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-014 | 19-Jul-97 | F | D 2 | 4 | 15-Apr-22 | 9:45:00 | Hematology | HAEMATOLOGY | N/A |
10 | 10-014 | 19-Jul-97 | F | D 7 EOS | 5 | 21-Apr-22 | 15:05:00 | Serum chemistry | BIOCHEMISTRY | Normal |
10 | 10-014 | 19-Jul-97 | F | D 7 EOS | 5 | 21-Apr-22 | 15:05:00 | Hematology | HAEMATOLOGY | N/A |
I want to merge this two datasets to generate a report to check the discrepancies between two and sort by date.
As the column data have repeated values i have used Proc SQL -Full join but i am not able to sort by date.Please anyone help me.
thanks!
Hi @Sri_devi,
it looks as if your date columns are character values.
If so, you have to convert them into date values: For an example:
Solved: convert character date to YYMMDD10. - SAS Support Communities
Best Regards
Markus
Have you tried proc sort?
As the column data have repeated values i have used Proc SQL -Full join but i am not able to sort by date.Please anyone help me.
Please post the code, the log and explain why do you think that sorting by date doesn't work.
code :proc SQL;
create table vendor_crf1 as select a.Site_number,a.Subject_ID,a.Date_of_birth,a.Gender,a.Visit_name,a.Sample_not_taken,a.Sample_date,a.Sample_time,a.CATGY,a.Laboratory_test,a.Clin_sign,
b.Vendor_Site_number,b.Vendor_Subject_ID,b.Vendor_Date_of_birth,b.Vendor_Gender,b.Vendor_Visit_name,b.Vendor_Sample_date,b.Vendor_Sample_time,b.Vendor_CATGY,b.CAT,b.TEST,b.Vendor_Clin_sign
from CRF_Demog as a FULL JOIN external as b on
a.Subject_ID = b.Vendor_Subject_ID and
a.Visit_name = b.Vendor_Visit_name and
a.Sample_date = b.Vendor_Sample_date and
a.Sample_time = b.Vendor_Sample_time and
a.CATGY = b.Vendor_CATGY ;
quit;
output generated :
Site_number | Subject_ID | Date_of_birth | Gender | Visit_name | Sample_not_taken | Sample_date | Sample_time | CATGY | Laboratory_test | Clin_sign | Vendor_Site_number | Vendor_Date_of_birth | Vendor_Gender | Vendor_Visit_name | Vendor_Vis_Num | Vendor_Sample_date | Vendor_Sample_time | Vendor_CATGY | CAT | Vendor_Clin_sign |
10 | 10-006 | 15-Jan-78 | M | D -1 | 31-Mar-22 | 13:24:00 | Hematology | Hematology -1 | No | 10 | 25-Jan-91 | F | D -1 | 2 | ######## | 13:24:00 | Hematology | HAEMATOLOGY | N/A | |
10 | 10-006 | 28-Nov-89 | F | D -1 | 31-Mar-22 | 13:24:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 25-Jan-91 | F | D -1 | 2 | ######## | 13:24:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-006 | 25-Nov-94 | M | D -1 | 31-Mar-22 | 13:24:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 25-Jan-91 | F | D -1 | 2 | ######## | 13:24:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-006 | 7-May-97 | M | D 1 POST 1HR | 1-Apr-22 | 11:19:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 25-Jan-91 | F | D 1 POST 1HR | 3 | 1-Apr-22 | 11:19:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-006 | 13-Nov-95 | M | D 1 POST 1HR | 1-Apr-22 | 11:19:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 25-Jan-91 | F | D 1 POST 1HR | 3 | 1-Apr-22 | 11:19:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-006 | 11-Feb-95 | F | D 1 POST 1HR | 1-Apr-22 | 11:19:00 | Hematology | Hematology -1 | No | 10 | 25-Jan-91 | F | D 1 POST 1HR | 3 | 1-Apr-22 | 11:19:00 | Hematology | HAEMATOLOGY | N/A | |
10 | 10-006 | 2-Dec-03 | F | D 2 | 2-Apr-22 | 10:22:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 25-Jan-91 | F | D 2 | 4 | 2-Apr-22 | 10:22:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-006 | 17-Mar-97 | F | D 2 | 2-Apr-22 | 10:22:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 25-Jan-91 | F | D 2 | 4 | 2-Apr-22 | 10:22:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-006 | 18-Sep-94 | F | D 2 | 2-Apr-22 | 10:22:00 | Hematology | Hematology -1 | No | 10 | 25-Jan-91 | F | D 2 | 4 | 2-Apr-22 | 10:22:00 | Hematology | HAEMATOLOGY | N/A | |
10 | 10-006 | 17-Jun-03 | M | D 7 EOS | 7-Apr-22 | 8:40:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 25-Jan-91 | F | D 7 EOS | 5 | 7-Apr-22 | 8:40:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-006 | 27-Jan-95 | M | D 7 EOS | 7-Apr-22 | 8:40:00 | Hematology | Hematology -1 | No | 10 | 25-Jan-91 | F | D 7 EOS | 5 | 7-Apr-22 | 8:40:00 | Hematology | HAEMATOLOGY | N/A | |
10 | 10-006 | 3-Nov-02 | M | D 7 EOS | 7-Apr-22 | 8:40:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 25-Jan-91 | F | D 7 EOS | 5 | 7-Apr-22 | 8:40:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-006 | 15-Mar-76 | M | SCREENING | 4-Mar-22 | 17:38:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 25-Jan-91 | F | SCREENING | 1 | 4-Mar-22 | 17:38:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-006 | 25-Jan-91 | F | SCREENING | 4-Mar-22 | 17:38:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 25-Jan-91 | F | SCREENING | 1 | 4-Mar-22 | 17:38:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-006 | 18-May-89 | F | SCREENING | 4-Mar-22 | 17:38:00 | Hematology | Hematology -1 | No | 10 | 25-Jan-91 | F | SCREENING | 1 | 4-Mar-22 | 17:38:00 | Hematology | HAEMATOLOGY | N/A | |
10 | 10-007 | 29-Apr-87 | M | D -1 | 31-Mar-22 | 13:20:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 15-Jan-78 | M | D -1 | 2 | ######## | 13:20:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-007 | 11-Oct-03 | M | D -1 | 31-Mar-22 | 13:20:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 15-Jan-78 | M | D -1 | 2 | ######## | 13:20:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-007 | 3-Jan-00 | F | D -1 | 31-Mar-22 | 13:20:00 | Hematology | Hematology -1 | No | 10 | 15-Jan-78 | M | D -1 | 2 | ######## | 13:20:00 | Hematology | HAEMATOLOGY | N/A | |
10 | 10-007 | 27-Mar-93 | M | D 1 POST 1HR | 1-Apr-22 | 12:22:00 | Hematology | Hematology -1 | No | 10 | 15-Jan-78 | M | D 1 POST 1HR | 3 | 1-Apr-22 | 12:22:00 | Hematology | HAEMATOLOGY | N/A | |
10 | 10-007 | 9-Jan-80 | F | D 1 POST 1HR | 1-Apr-22 | 12:22:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 15-Jan-78 | M | D 1 POST 1HR | 3 | 1-Apr-22 | 12:22:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-007 | 24-May-95 | F | D 1 POST 1HR | 1-Apr-22 | 12:22:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 15-Jan-78 | M | D 1 POST 1HR | 3 | 1-Apr-22 | 12:22:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-007 | 7-Jun-94 | M | D 2 | 2-Apr-22 | 11:22:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 15-Jan-78 | M | D 2 | 4 | 2-Apr-22 | 11:22:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-007 | 26-Apr-96 | M | D 2 | 2-Apr-22 | 11:22:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 15-Jan-78 | M | D 2 | 4 | 2-Apr-22 | 11:22:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-007 | 11-Sep-00 | F | D 2 | 2-Apr-22 | 11:22:00 | Hematology | Hematology -1 | No | 10 | 15-Jan-78 | M | D 2 | 4 | 2-Apr-22 | 11:22:00 | Hematology | HAEMATOLOGY | N/A | |
10 | 10-007 | D 7 EOS | 7-Apr-22 | 10:00:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 15-Jan-78 | M | D 7 EOS | 5 | 7-Apr-22 | 10:00:00 | Serum chemistry | BIOCHEMISTRY | Normal | |||
10 | 10-007 | D 7 EOS | 7-Apr-22 | 10:00:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 15-Jan-78 | M | D 7 EOS | 5 | 7-Apr-22 | 10:00:00 | Serum chemistry | BIOCHEMISTRY | Normal | |||
10 | 10-007 | 21-Mar-94 | M | D 7 EOS | 7-Apr-22 | 10:00:00 | Hematology | Hematology -1 | No | 10 | 15-Jan-78 | M | D 7 EOS | 5 | 7-Apr-22 | 10:00:00 | Hematology | HAEMATOLOGY | N/A | |
10 | 10-007 | 5-Jul-96 | M | SCREENING | 9-Mar-22 | 14:45:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 15-Jan-78 | M | SCREENING | 1 | 9-Mar-22 | 14:45:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-007 | 17-Jul-96 | F | SCREENING | 9-Mar-22 | 14:45:00 | Hematology | Hematology -1 | No | 10 | 15-Jan-78 | M | SCREENING | 1 | 9-Mar-22 | 14:45:00 | Hematology | HAEMATOLOGY | N/A | |
10 | 10-007 | 1-Feb-01 | M | SCREENING | 9-Mar-22 | 14:45:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 15-Jan-78 | M | SCREENING | 1 | 9-Mar-22 | 14:45:00 | Serum chemistry | BIOCHEMISTRY | Normal | |
10 | 10-014 | D -1 | 13-Apr-22 | 13:31:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 19-Jul-97 | F | D -1 | 2 | ######## | 13:31:00 | Serum chemistry | BIOCHEMISTRY | Normal | |||
10 | 10-014 | D -1 | 13-Apr-22 | 13:31:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 19-Jul-97 | F | D -1 | 2 | ######## | 13:31:00 | Serum chemistry | BIOCHEMISTRY | Normal | |||
10 | 10-014 | D -1 | 13-Apr-22 | 13:31:00 | Hematology | Hematology -1 | No | 10 | 19-Jul-97 | F | D -1 | 2 | ######## | 13:31:00 | Hematology | HAEMATOLOGY | N/A | |||
10 | 10-014 | D 1 POST 1HR | 14-Apr-22 | 10:45:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 19-Jul-97 | F | D 1 POST 1HR | 3 | ######## | 10:45:00 | Serum chemistry | BIOCHEMISTRY | Normal | |||
10 | 10-014 | D 1 POST 1HR | 14-Apr-22 | 10:45:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 19-Jul-97 | F | D 1 POST 1HR | 3 | ######## | 10:45:00 | Serum chemistry | BIOCHEMISTRY | Normal | |||
10 | 10-014 | D 1 POST 1HR | 14-Apr-22 | 10:45:00 | Hematology | Hematology -1 | No | 10 | 19-Jul-97 | F | D 1 POST 1HR | 3 | ######## | 10:45:00 | Hematology | HAEMATOLOGY | N/A |
Output want :
different with above output is i want the the date columns(sample_date & vendor_sample_date) to be sorted as shown below.
Site_number | Subject_ID | Date_of_birth | Gender | Visit_name | Sample_not_taken | Sample_date | Sample_time | CATGY | Laboratory_test | Clin_sign | Vendor_Site_number | Vendor_Date_of_birth | Vendor_Gender | Vendor_Visit_name | Vendor_Vis_Num | Vendor_Sample_date | Vendor_Sample_time | Vendor_CATGY | CAT | Vendor_Clin_sign | |
10 | 10-006 | 15-Mar-76 | M | SCREENING | 4-Mar-22 | 17:38:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 25-Jan-91 | F | SCREENING | 1 | 4-Mar-22 | 17:38:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-006 | 25-Jan-91 | F | SCREENING | 4-Mar-22 | 17:38:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 25-Jan-91 | F | SCREENING | 1 | 4-Mar-22 | 17:38:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-006 | 18-May-89 | F | SCREENING | 4-Mar-22 | 17:38:00 | Hematology | Hematology -1 | No | 10 | 25-Jan-91 | F | SCREENING | 1 | 4-Mar-22 | 17:38:00 | Hematology | HAEMATOLOGY | N/A | ||
10 | 10-007 | 5-Jul-96 | M | SCREENING | 9-Mar-22 | 14:45:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 15-Jan-78 | M | SCREENING | 1 | 9-Mar-22 | 14:45:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-007 | 17-Jul-96 | F | SCREENING | 9-Mar-22 | 14:45:00 | Hematology | Hematology -1 | No | 10 | 15-Jan-78 | M | SCREENING | 1 | 9-Mar-22 | 14:45:00 | Hematology | HAEMATOLOGY | N/A | ||
10 | 10-007 | 1-Feb-01 | M | SCREENING | 9-Mar-22 | 14:45:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 15-Jan-78 | M | SCREENING | 1 | 9-Mar-22 | 14:45:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-006 | 15-Jan-78 | M | D -1 | 31-Mar-22 | 13:24:00 | Hematology | Hematology -1 | No | 10 | 25-Jan-91 | F | D -1 | 2 | 31-Mar-22 | 13:24:00 | Hematology | HAEMATOLOGY | N/A | ||
10 | 10-006 | 28-Nov-89 | F | D -1 | 31-Mar-22 | 13:24:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 25-Jan-91 | F | D -1 | 2 | 31-Mar-22 | 13:24:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-006 | 25-Nov-94 | M | D -1 | 31-Mar-22 | 13:24:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 25-Jan-91 | F | D -1 | 2 | 31-Mar-22 | 13:24:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-007 | 29-Apr-87 | M | D -1 | 31-Mar-22 | 13:20:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 15-Jan-78 | M | D -1 | 2 | 31-Mar-22 | 13:20:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-007 | 11-Oct-03 | M | D -1 | 31-Mar-22 | 13:20:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 15-Jan-78 | M | D -1 | 2 | 31-Mar-22 | 13:20:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-007 | 3-Jan-00 | F | D -1 | 31-Mar-22 | 13:20:00 | Hematology | Hematology -1 | No | 10 | 15-Jan-78 | M | D -1 | 2 | 31-Mar-22 | 13:20:00 | Hematology | HAEMATOLOGY | N/A | ||
10 | 10-006 | 7-May-97 | M | D 1 POST 1HR | 1-Apr-22 | 11:19:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 25-Jan-91 | F | D 1 POST 1HR | 3 | 1-Apr-22 | 11:19:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-006 | 13-Nov-95 | M | D 1 POST 1HR | 1-Apr-22 | 11:19:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 25-Jan-91 | F | D 1 POST 1HR | 3 | 1-Apr-22 | 11:19:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-006 | 11-Feb-95 | F | D 1 POST 1HR | 1-Apr-22 | 11:19:00 | Hematology | Hematology -1 | No | 10 | 25-Jan-91 | F | D 1 POST 1HR | 3 | 1-Apr-22 | 11:19:00 | Hematology | HAEMATOLOGY | N/A | ||
10 | 10-007 | 27-Mar-93 | M | D 1 POST 1HR | 1-Apr-22 | 12:22:00 | Hematology | Hematology -1 | No | 10 | 15-Jan-78 | M | D 1 POST 1HR | 3 | 1-Apr-22 | 12:22:00 | Hematology | HAEMATOLOGY | N/A | ||
10 | 10-007 | 9-Jan-80 | F | D 1 POST 1HR | 1-Apr-22 | 12:22:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 15-Jan-78 | M | D 1 POST 1HR | 3 | 1-Apr-22 | 12:22:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-007 | 24-May-95 | F | D 1 POST 1HR | 1-Apr-22 | 12:22:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 15-Jan-78 | M | D 1 POST 1HR | 3 | 1-Apr-22 | 12:22:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-006 | 2-Dec-03 | F | D 2 | 2-Apr-22 | 10:22:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 25-Jan-91 | F | D 2 | 4 | 2-Apr-22 | 10:22:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-006 | 17-Mar-97 | F | D 2 | 2-Apr-22 | 10:22:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 25-Jan-91 | F | D 2 | 4 | 2-Apr-22 | 10:22:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-006 | 18-Sep-94 | F | D 2 | 2-Apr-22 | 10:22:00 | Hematology | Hematology -1 | No | 10 | 25-Jan-91 | F | D 2 | 4 | 2-Apr-22 | 10:22:00 | Hematology | HAEMATOLOGY | N/A | ||
10 | 10-007 | 7-Jun-94 | M | D 2 | 2-Apr-22 | 11:22:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 15-Jan-78 | M | D 2 | 4 | 2-Apr-22 | 11:22:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-007 | 26-Apr-96 | M | D 2 | 2-Apr-22 | 11:22:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 15-Jan-78 | M | D 2 | 4 | 2-Apr-22 | 11:22:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-007 | 11-Sep-00 | F | D 2 | 2-Apr-22 | 11:22:00 | Hematology | Hematology -1 | No | 10 | 15-Jan-78 | M | D 2 | 4 | 2-Apr-22 | 11:22:00 | Hematology | HAEMATOLOGY | N/A | ||
10 | 10-006 | 17-Jun-03 | M | D 7 EOS | 7-Apr-22 | 8:40:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 25-Jan-91 | F | D 7 EOS | 5 | 7-Apr-22 | 8:40:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-006 | 27-Jan-95 | M | D 7 EOS | 7-Apr-22 | 8:40:00 | Hematology | Hematology -1 | No | 10 | 25-Jan-91 | F | D 7 EOS | 5 | 7-Apr-22 | 8:40:00 | Hematology | HAEMATOLOGY | N/A | ||
10 | 10-006 | 3-Nov-02 | M | D 7 EOS | 7-Apr-22 | 8:40:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 25-Jan-91 | F | D 7 EOS | 5 | 7-Apr-22 | 8:40:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||
10 | 10-007 | D 7 EOS | 7-Apr-22 | 10:00:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 15-Jan-78 | M | D 7 EOS | 5 | 7-Apr-22 | 10:00:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||||
10 | 10-007 | D 7 EOS | 7-Apr-22 | 10:00:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 15-Jan-78 | M | D 7 EOS | 5 | 7-Apr-22 | 10:00:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||||
10 | 10-007 | 21-Mar-94 | M | D 7 EOS | 7-Apr-22 | 10:00:00 | Hematology | Hematology -1 | No | 10 | 15-Jan-78 | M | D 7 EOS | 5 | 7-Apr-22 | 10:00:00 | Hematology | HAEMATOLOGY | N/A | ||
10 | 10-014 | D -1 | 13-Apr-22 | 13:31:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 19-Jul-97 | F | D -1 | 2 | 13-Apr-22 | 13:31:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||||
10 | 10-014 | D -1 | 13-Apr-22 | 13:31:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 19-Jul-97 | F | D -1 | 2 | 13-Apr-22 | 13:31:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||||
10 | 10-014 | D -1 | 13-Apr-22 | 13:31:00 | Hematology | Hematology -1 | No | 10 | 19-Jul-97 | F | D -1 | 2 | 13-Apr-22 | 13:31:00 | Hematology | HAEMATOLOGY | N/A | ||||
10 | 10-014 | D 1 POST 1HR | 14-Apr-22 | 10:45:00 | Serum chemistry | Thyroid assessment -1 | No | 10 | 19-Jul-97 | F | D 1 POST 1HR | 3 | 14-Apr-22 | 10:45:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||||
10 | 10-014 | D 1 POST 1HR | 14-Apr-22 | 10:45:00 | Serum chemistry | Serum chemistry -1 | No | 10 | 19-Jul-97 | F | D 1 POST 1HR | 3 | 14-Apr-22 | 10:45:00 | Serum chemistry | BIOCHEMISTRY | Normal | ||||
10 | 10-014 | D 1 POST 1HR | 14-Apr-22 | 10:45:00 | Hematology | Hematology -1 | No | 10 | 19-Jul-97 | F | D 1 POST 1HR | 3 | 14-Apr-22 | 10:45:00 | Hematology | HAEMATOLOGY | N/A |
If you want a specific sort order from SQL, you must tell it so:
proc sql;
create table vendor_crf1 as
select
a.Site_number,a.Subject_ID,a.Date_of_birth,a.Gender,a.Visit_name,a.Sample_not_taken,a.Sample_date,a.Sample_time,a.CATGY,a.Laboratory_test,a.Clin_sign,
b.Vendor_Site_number,b.Vendor_Subject_ID,b.Vendor_Date_of_birth,b.Vendor_Gender,b.Vendor_Visit_name,b.Vendor_Sample_date,b.Vendor_Sample_time,b.Vendor_CATGY,b.CAT,b.TEST,b.Vendor_Clin_sign,
coalesce(a.sample_date,b.vendor_sample_date) as s_date, coalesce(a.sample_time,b.vendor_sample_time) as s_time
from CRF_Demog as a FULL JOIN external as b on
a.Subject_ID = b.Vendor_Subject_ID and
a.Visit_name = b.Vendor_Visit_name and
a.Sample_date = b.Vendor_Sample_date and
a.Sample_time = b.Vendor_Sample_time and
a.CATGY = b.Vendor_CATGY
order by
s_date, s_time
;
quit;
The COALESCEd variables are necessary because of the FULL JOIN.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.