Using the LIKE Clause

LIKE Clause Syntax

Suppose you need to create a new table. The new table must contain the same columns and attributes as an existing table, but no rows. You can use a CREATE TABLE statement with a LIKE clause to create an empty table that is like another table.
Syntax, CREATE TABLE statement with a LIKE clause:
CREATE TABLE table-name
LIKE table-1;
table-name
specifies the name of the table to be created.
table-1
specifies the table whose columns and attributes will be copied to the new table.

Example: Creating an Empty Table That Is like Another

Suppose you want to create a new table, Work.Flightdelays2, that contains data about flight delays. You would like the new table to contain the same columns and attributes as the existing table Certadv.Flightdelays, but you do not want to include any of the existing data. The following PROC SQL step uses a CREATE TABLE statement and a LIKE clause to create Work.Flightdelays2:
proc sql;
   create table work.flightdelays2
      like certadv.flightdelays;
quit;
Work.FlightDelays2 contains 0 rows and 8 columns.
Last updated: October 16, 2019
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset