Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How come SAS, Proc SQL, doesn't throw an error when I CREATE already existing tables

SAS Beginner here.

INTRO: In SQL Server Management Studio an error is thrown when you try to CREATE an object/table that already exists. So the solution is to first DROP the table and then CREATE it.

So how come in SAS I can write something like this... (pretending that the Example table exists)

PROC SQL;
    CREATE TABLE Example AS
        SELECT *
        FROM Work.Test;
QUIT;

QUESTION: Even though the Example object/table already exists, no error is thrown. Does anyone know why SAS or SQL Server Management Studio are different in this regard?

like image 891
frango_mints Avatar asked Oct 30 '15 19:10

frango_mints


People also ask

Is SAS PROC SQL the same as SQL?

PROC SQL is part of the BASE SAS® software and allows you to use SQL within the SAS® system. PROC SQL has many capabilities, benefits, and advantages within the SAS® system. It can reduce the amount of processing time and amount of code, in some cases, when compared to non-SQL base SAS® code, data step and proc steps.

How do you update a table in SAS?

You can use the UPDATE statement to modify data values in tables and in the tables that underlie PROC SQL and SAS/ACCESS views. For more information about updating views, see Creating and Using PROC SQL Views. The UPDATE statement updates data in existing columns; it does not create new columns.

What does PROC SQL do in SAS?

PROC SQL is a powerful Base SAS Procedure that combines the functionality of DATA and PROC steps into a single step. PROC SQL can sort, summarize, subset, join (merge), and concatenate datasets, create new variables, and print the results or create a new table or view all in one step!


1 Answers

SAS has a default OPTION REPLACE, which tells SAS that you would like to allow this behavior.

If you wish to disable this feature, set OPTION NOREPLACE. As the documentation above states, this would not prevent the above from executing, however, because it is in the work library (which is a temporary library).

As to the why (why things are different), it is undoubtedly due to historical differences in how the languages are used. SAS isn't really a database language (though it shares heavily with them, including the built-in PROC SQL); it's also substantially older than SQL Server (origins in the 1960s and even before in PL/1 and PL/2). SQL Server gives you lots of tools for updating a table in place; SAS has many of those tools, but for various reasons SAS programmers tend to replace tables rather than updating them in place.

like image 126
Joe Avatar answered Nov 14 '22 21:11

Joe