SAS Support Site Home | Samples and SAS Notes Home
SAS Notes V6-SQL-D929
PROC SQL DISTINCT or PROC SORT NODUPKEY output may still have duplicates


The output from PROC SQL with DISTINCT and PROC SORT with a NODUPKEY option can still have duplicates in the results. The problem occurs if the data set was created in PROC SQL as the result of an UNION of two ormore tables which included an unnamed/calculated field. The SORTEDBY information in the header of the data set does not include this variableeven though it was used in the the removal of duplicates in the UNION. If the data set is sorted in a later step, decisions are based on that incorrect information which can cause duplicates to not be removed.

    PROC SQL;
      CREATE TABLE TEST AS SELECT X,1 FROM ONE UNION SELECT X,2 FROM TWO;

The SORTEDBY field will only list variable X. If you give the other column a name both will show up in the SORTEDBY field.

    SELECT X,1 as DSNUM

The problem has been corrected for Releases 6.09E at TSLEVEL 460 and for Release 6.12 at TSLEVEL 045.


Products: BASE
Component: SQL
Priority: MED
Status: Outstanding Problem
Date: Fri, 15 May 1998

System Release Reported Release Fixed
VM/ESA (CMS) 6.06 6.09 TS460  
OS/390 (MVS) 6.06 6.09 TS460  
OpenVMS VAX 6.06 6.09 TS460  
Data General AOS/VS 6.06  
Primos 6.06  
HP - Apollo 6.07 TS101  
AIX/6000 6.07 TS101 6.12 TS045  
Data General Aviion 6.07 TS101  
HP-UX Operating Systems 6.07 TS101  
Silicon Graphics Unix 6.07 TS101  
DEC Ultrix 6.07 TS101  
BULL 6.07 TS201  
HP-UX Operating Systems 6.07 TS201 6.12 TS045  
NeXT 6.07 TS201  
Silicon Graphics - IRIX 6.07 TS201  
Siemens Unix 6.07 TS201  
SunOS 3.0 6.07 TS201  
SunOS 4.0 6.07 TS201 6.12 TS045  
IBM OS/2 6.08 TS404 6.12 TS045  
Windows 3.11 6.08 TS404 6.12 TS045  
ConvexOS 6.09 TS027  
Solaris 6.09 TS027 6.12 TS045  
Windows NT 6.09 TS027 6.12 TS045  
OpenVMS Alpha 6.09 TS027 6.12 TS045  
DEC Ultrix 6.09 TS027  
AIX/6000 6.11 TS020 6.12 TS045  
HP-UX Operating Systems 6.12 TS020 6.12 TS045  
Windows 95 6.12 TS020 6.12 TS045  

No Fixes Available