Usage Note 36024: An error occurs when you try to merge data sets with an alternative character-collating sequence set in the SORTSEQ= option
In SAS 9.2®, when you try to merge two data sets and you have set the SORTSEQ= option globally to specify an alternative character-collating sequence, you might receive the following error message stating that the input data sets cannot be combined because they have different collating sequences:
ERROR: Input data sets cannot be combined because they have different
collating sequences (SORTSEQ).
This error can happen if one of the data sets involved has not been explicitly sorted but it is using a default collating sequence (for example ASCII on an ASCII-based machine). No explicit collating sequence is set in the data-set header in this case. This occurs because SAS® is running on a platform that uses ASCII-based session encodings, and the ASCII collating sequence (SORTSEQ=ASCII) is considered redundant. As a result, SAS sets the collating sequence to all blanks to indicate that the default collating sequence for that platform was used. The following example provokes this error:
options sortseq=national;
data test1;
input v1 $ v2 $;
datalines;
a 1
b 1
c 1
;
data test2;
input v1 $ v3 $;
datalines;
c 1
b 1
a 1
;
run;
proc sort data=test2;
by v1;
run;
data test3;
merge test1 test2;
by v1;
run;
The error occurs to prevent data that has not been sorted with the same collating sequence from being merged with other data.
To fix this you need to ensure that both data sets are sorted. Alternatively, if you know that the data set is sorted, you can apply a weak assertion, which you set via a data set option. In the following example, the weak assertion is set with the SORTEDBY= option:
data test1(sortedby=v1/national);
input v1 $ v2 $;
datalines;
a 1
b 1
c 1
;
You can also apply a strong assertion, which is set by the SORT procedure. In the following example, the strong assertion is indicated with the PRESORTED option. PROC SORT skips the sorting process when it encounters a strong assertion that the data has been sorted.
data test1;
input v1 $ v2 $;
datalines;
a 1
b 1
c 1
;
proc sort data=test1 presorted;
by v1;
run;
Operating System and Release Information
| SAS System | Base SAS | z/OS | 9.2 TS2M2 | |
| Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS2M2 | |
| Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS2M2 | |
| Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS2M2 | |
| Microsoft Windows XP 64-bit Edition | 9.2 TS2M2 | |
| Microsoft® Windows® for x64 | 9.2 TS2M2 | |
| Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS2M2 | |
| Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS2M2 | |
| Microsoft Windows Server 2003 Standard Edition | 9.2 TS2M2 | |
| Microsoft Windows XP Professional | 9.2 TS2M2 | |
| Windows Vista | 9.2 TS2M2 | |
| 64-bit Enabled AIX | 9.2 TS2M2 | |
| 64-bit Enabled HP-UX | 9.2 TS2M2 | |
| 64-bit Enabled Solaris | 9.2 TS2M2 | |
| HP-UX IPF | 9.2 TS2M2 | |
| Linux | 9.2 TS2M2 | |
| Linux for x64 | 9.2 TS2M2 | |
| OpenVMS on HP Integrity | 9.2 TS2M2 | |
| Solaris for x64 | 9.2 TS2M2 | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
This is the code that will provoke an error message in 9.2.
options sortseq=national;
data test1;
input v1 $ v2 $;
datalines;
a 1
b 1
c 1
;
data test2;
input v1 $ v3 $;
datalines;
c 1
b 1
a 1
;
run;
proc sort data = test2;
by v1;
run;
data test3;
merge test1 test2;
by v1;
run;
When you try to merge two data sets and you have set the SORTSEQ= option to specify an alternative character-collating sequence, you might receive an error message saying that the input data sets cannot be combined because they have different collating sequences.
| Type: | Usage Note |
| Priority: | |
| Topic: | Common Programming Tasks ==> Sorting Data Common Programming Tasks ==> Combining Data Data Management ==> Manipulation and Transformation ==> Combining and Modifying Data Sets SAS Reference ==> DATA Step SAS Reference ==> Statements ==> File-handling ==> MERGE Common Programming Tasks ==> Working with Character Data
|
| Date Modified: | 2009-10-14 15:22:50 |
| Date Created: | 2009-05-22 08:12:25 |