Problem Note 12330: "ERROR: Close of OUTPUT file WORK.XYZ.DATA failed; Another copy of the
file is still open for INPUT; file not replaced."
If you try to overwrite the table you select from in PROC SQL, you might
encounter an error:
ERROR: Close of OUTPUT file WORK.XYZ.DATA failed
The following code shows the problem:
data test;
value=1;
run;
proc sql;
create table test
as select * from test
where value gt 0
and value lt 0; /* where clause is always false */
quit;
This construction (CREATE TABLE AS) is non-ansi compliant. It's
convenience to SAS customers, and is equivalent to a CREATE TABLE
followed by INSERT INTO. ANSI SQL/92 does not allow to insert data into
the same table that the data is coming from.
In SAS 9 we generate a warning:
WARNING: This CREATE TABLE statement recursively references the target
table. A consequence of this is a possible data integrity
problem.
In order to circumvent, don't use predicates that always resolves to
false or use a DATA Step:
data test;
set test;
where value lt 0 and value gt 0;
run;
Operating System and Release Information
| SAS System | Base SAS | Microsoft Windows NT Workstation | 8.2 TS2M0 | |
| Microsoft Windows XP Professional | 8.2 TS2M0 | |
| Microsoft Windows Server 2003 Enterprise Edition | 8.2 TS2M0 | |
| Microsoft Windows Server 2003 Standard Edition | 8.2 TS2M0 | |
| Microsoft Windows 95/98 | 8.2 TS2M0 | |
| Windows Millennium Edition (Me) | 8.2 TS2M0 | |
| Microsoft Windows 2000 Server | 8.2 TS2M0 | |
| Microsoft Windows Server 2003 Datacenter Edition | 8.2 TS2M0 | |
| Microsoft Windows 2000 Advanced Server | 8.2 TS2M0 | |
| Microsoft Windows 2000 Datacenter Server | 8.2 TS2M0 | |
| Microsoft Windows 2000 Professional | 8.2 TS2M0 | |
*
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.
| Type: | Problem Note |
| Priority: | medium |
| Topic: | SAS Reference ==> SQL SAS Reference ==> Procedures ==> SQL
|
| Date Modified: | 2004-09-20 16:10:47 |
| Date Created: | 2004-05-04 13:46:32 |