InterviewSolution
| 1. |
How can we create an index? |
|
Answer» There are multiple ways for creating table in PROC sql I. Create Table From Column Definition We can create a NEW table without rows by using the CREATE TABLE statement to define the columns and attributes. We can specify a column’s NAME, type, length, informat, format and label. procsql; createtable employee( ssn CHAR(9), dob numformat = DATE9.informat = DATE9.label = "Date Of Birth", doh numformat = DATE9.informat = DATE9.label = "Date Of Hire", GENDER char(1) label = "Gender", estat char(10) label = "Employement Status"); insertinto employee values ("111111111",500,25000,"M","ACTIVE"); quit; procsql; select * from employee; quit;II. Create Table from a Query Result Many times, there are situations wherein we already have a structure of the table/view and we are trying to create a mirror table that is referring to columns of the earlier existing table. In such cases, we can use the same CREATE TABLE Statement and place it before the SELECT Statement. An additional benefit of using this approach of creating the table is that the data of the new table is derived on the basis of existing data from the parent table. procsql; createtable employee1 as select * from employee quit; procsql; select * from employee1; quit;III. Create Table Like an Existing Table To create an empty table that has the same columns and attributes as an existing table, we use the LIKE clause while creating the table. One point to note is that an empty table is created using this method and no data is populated inside the table. procsql;createtable employee3 like employee; quit; |
|