## One date not present in other date

Solved
Frequent Contributor
Posts: 147

# One date not present in other date

470010001           INITIAL DIAGNOSIS                19054                    19047

470010001           INITIAL DIAGNOSIS                19054                    19054

470010002           INITIAL DIAGNOSIS                18641                    18641

470010002           INITIAL DIAGNOSIS                18641                    18683

470010003           INITIAL DIAGNOSIS                18059                    18045

470010003           INITIAL DIAGNOSIS                18059                    18059

470010005           INITIAL DIAGNOSIS 18133                    18124

470010005           INITIAL DIAGNOSIS 18133                    18150

470010007           INITIAL DIAGNOSIS 16880                    16220

470010007           INITIAL DIAGNOSIS 16880                    17853

Hi,

I have the following data with variables id, term, date1, date2 .

I want create a table to select id’s whose date1 is not present in date2. In the above data  the id(470001005,470010007) marked in yellow are discrepancy  as their date 1 is not present in date2. We need to pull out those kind of records.

The id’s marked in red are good as their date1 is matching atleast one of the date2 for that particular subject.

Accepted Solutions
Solution
‎05-12-2014 10:24 AM
Super User
Posts: 10,766

## Re: One date not present in other date

```data have;
input  id :\$20. term & \$40. date1 date2;
cards;
470010001           INITIAL DIAGNOSIS                19054                    19047
470010001           INITIAL DIAGNOSIS                19054                    19054
470010002           INITIAL DIAGNOSIS                18641                    18641
470010002           INITIAL DIAGNOSIS                18641                    18683
470010003           INITIAL DIAGNOSIS                18059                    18045
470010003           INITIAL DIAGNOSIS                18059                    18059
470010005           INITIAL DIAGNOSIS  18133                    18124
470010005           INITIAL DIAGNOSIS   18133                    18150
470010007           INITIAL DIAGNOSIS  16880                    16220
470010007           INITIAL DIAGNOSIS  16880                    17853
;
run;
proc sql;
create table want as
select * from have group by id having sum(date1=date2)=0;
quit;

```

Xia Keshan

All Replies
Solution
‎05-12-2014 10:24 AM
Super User
Posts: 10,766

## Re: One date not present in other date

```data have;
input  id :\$20. term & \$40. date1 date2;
cards;
470010001           INITIAL DIAGNOSIS                19054                    19047
470010001           INITIAL DIAGNOSIS                19054                    19054
470010002           INITIAL DIAGNOSIS                18641                    18641
470010002           INITIAL DIAGNOSIS                18641                    18683
470010003           INITIAL DIAGNOSIS                18059                    18045
470010003           INITIAL DIAGNOSIS                18059                    18059
470010005           INITIAL DIAGNOSIS  18133                    18124
470010005           INITIAL DIAGNOSIS   18133                    18150
470010007           INITIAL DIAGNOSIS  16880                    16220
470010007           INITIAL DIAGNOSIS  16880                    17853
;
run;
proc sql;
create table want as
select * from have group by id having sum(date1=date2)=0;
quit;

```

Xia Keshan

🔒 This topic is solved and locked.