Chapter 5: Creating And Managing Tables Using Proc SQL

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Moxleyv
M
Moxleyv
Community Contributor
Quizzes Created: 38 | Total Attempts: 20,684
Questions: 10 | Attempts: 104

SettingsSettingsSettings
Chapter 5: Creating And Managing Tables Using Proc SQL - Quiz


Practice for the SAS advance certification exam


Questions and Answers
  • 1. 

    Which of the following PROC SQL steps creates a new table by copying only the column structure (but not the rows) of an existing table?

    • A.

      proc sql; create table work.newpayroll as select * from sasuser.payrollmaster;

    • B.

      proc sql; create table work.newpayroll like sasuser.payrollmaster;

    • C.

      proc sql; create table work.newpayroll copy sasuser.payrollmaster;

    • D.

      proc sql; create table work.newpayroll describe sasuser.payrollmaster;

    Correct Answer
    B. proc sql; create table work.newpayroll like sasuser.payrollmaster;
    Explanation
    The CREATE TABLE statement that includes a LIKE clause copies the column names and attributes from an existing table into a new table. No rows of data are inserted.

    Rate this question:

  • 2. 

    Which of the following PROC SQL steps creates a table that contains rows for the level-1 flight attendants only?

    • A.

      proc sql; create table work.newpayroll as select * from sasuser.payrollmaster where jobcode='FA1';

    • B.

      proc sql; create work.newpayroll as select * from sasuser.payrollmaster where jobcode='FA1';

    • C.

      proc sql; create table work.newpayroll copy sasuser.payrollmaster where jobcode='FA1';

    • D.

      proc sql; create table work.newpayroll as sasuser.payrollmaster where jobcode='FA1';

    Correct Answer
    A. proc sql; create table work.newpayroll as select * from sasuser.payrollmaster where jobcode='FA1';
    Explanation
    The CREATE TABLE statement that includes the AS keyword and query clauses creates a table and loads the results of the query into the new table. The WHERE clause selects only the rows for the level-1 flight attendants.

    Rate this question:

  • 3. 

    Which of the following statements is true regarding the UNDO_POLICY=REQUIRED option?

    • A.

      It must be used with the REQUIRED integrity constraint.

    • B.

      It ignores the specified integrity constraints if any of the rows that you want to insert or update do not meet the constraint criteria.

    • C.

      It restores your table to its original state if any of the rows that you try to insert or update do not meet the specified integrity constraint criteria.

    • D.

      It allows rows that meet the specified integrity constraint criteria to be inserted or updated, but rejects rows that do not meet the integrity constraint criteria.

    Correct Answer
    C. It restores your table to its original state if any of the rows that you try to insert or update do not meet the specified integrity constraint criteria.
    Explanation
    UNDO POLICY=REQUIRED is the default setting for PROC SQL. This setting undoes all inserts or updates if 1 or more rows violate the integrity constraint criteria, and restores the table to its original state before the inserts or updates.

    Rate this question:

  • 4. 

    Which of the following is not a type of integrity constraint?

    • A.

      CHECK

    • B.

      NULL

    • C.

      UNIQUE

    • D.

      PRIMARY KEY

    Correct Answer
    B. NULL
    Explanation
    The NOT NULL integrity constraint specifies that data is required and cannot have a null (missing) value.

    Rate this question:

  • 5. 

    Which of the following PROC SQL steps deletes rows for all frequent-flyer program members who traveled less than 10,000 miles?

    • A.

      proc sql; delete rows from work.frequentflyers where milestraveled < 10000;

    • B.

      proc sql; drop rows from work.frequentflyers where milestraveled < 10000;

    • C.

      proc sql; drop table from work.frequentflyers where milestraveled < 10000;

    • D.

      proc sql; delete from work.frequentflyers where milestraveled < 10000;

    Correct Answer
    D. proc sql; delete from work.frequentflyers where milestraveled < 10000;
    Explanation
    The DELETE statement deletes rows that are specified in the WHERE clause from the table. If no WHERE clause is specified, all rows are deleted. The DROP TABLE statement drops (deletes) an entire table; the syntax shown in option c is not valid.

    Rate this question:

  • 6. 

    Which of the following PROC SQL steps gives bonuses (in points) to frequent-flyer program members as follows:
    • a 50% bonus for members who traveled less than 10,000 miles
    • a 100% bonus for members who traveled 10,000 miles or more?

    • A.

      proc sql; update work.frequentflyers set pointsearned=pointsearned* case if milestraveled < 10000 then 1.5 if milestraveled >= 10000 then 2 else 1 end;

    • B.

      proc sql; update work.frequentflyers set pointsearned=pointsearned* case when milestraveled < 10000 then 1.5 when milestraveled >= 10000 then 2 else 1 end;

    • C.

      proc sql; update work.frequentflyers set pointsearned=pointsearned* case if milestraveled < 10000 then pointsearned*1.5 if milestraveled >= 10000 then pointsearned*2 else 1 end;

    • D.

      proc sql; update work.frequentflyers set pointsearned=pointsearned* case if milestraveled < 10000 then pointsearned*1.5 if milestraveled >= 10000 then pointsearned*2 else pointsearned*1 end;

    Correct Answer
    B. proc sql; update work.frequentflyers set pointsearned=pointsearned* case when milestraveled < 10000 then 1.5 when milestraveled >= 10000 then 2 else 1 end;
    Explanation
    The UPDATE statement that includes a SET clause is used to modify rows in a table. WHEN-THEN clauses in the CASE expression enable you to update a column value based on specified criteria.

    Rate this question:

  • 7. 

    Which of the following statements is used to add new rows to a table?

    • A.

      INSERT

    • B.

      LOAD

    • C.

      VALUES

    • D.

      CREATE TABLE

    Correct Answer
    A. INSERT
    Explanation
    The INSERT statement is used to insert new rows into a new or existing table. There is no LOAD statement in PROC SQL, VALUES is a clause, and the CREATE TABLE statement is used to create a table.

    Rate this question:

  • 8. 

    Which of the following statements regarding the ALTER TABLE statement is false?

    • A.

      It allows you to update column attributes.

    • B.

      It allows you to add new columns in your table.

    • C.

      It allows you to drop columns in your table.

    • D.

      It allows you to change a character column to a numeric column.

    Correct Answer
    D. It allows you to change a character column to a numeric column.
    Explanation
    The ALTER TABLE statement is used to modify attributes of existing columns (include the MODIFY clause), add new column definitions (include the ADD clause), or delete existing columns (include the DROP clause).

    Rate this question:

  • 9. 

    Which of the following displays the structure of a table in the SAS log?

    • A.

      proc sql; describe as select * from sasuser.payrollmaster;

    • B.

      proc sql; describe contents sasuser.payrollmaster;

    • C.

      proc sql; describe table sasuser.payrollmaster;

    • D.

      proc sql; describe * from sasuser.payrollmaster;

    Correct Answer
    C. proc sql; describe table sasuser.payrollmaster;
    Explanation
    The DESCRIBE TABLE statement lists the column attributes for a specified table.

    Rate this question:

  • 10. 

    Which of the following creates an empty table that contains the 2 columns FullName and Age?

    • A.

      proc sql; create table work.names (FullName char(25), Age num);

    • B.

      proc sql; create table work.names as (FullName char(25), Age num);

    • C.

      proc sql; create work.names (FullName char(25), Age num);

    • D.

      proc sql; create table work.names set (FullName char(25), Age num);

    Correct Answer
    A. proc sql; create table work.names (FullName char(25), Age num);
    Explanation
    The CREATE TABLE statement can include column specifications to create an empty table. The entire group of column specifications must be enclosed in a single set of parentheses. You must list each column's name, data type, and (for character columns) length. The length is specified as an integer in parentheses. Multiple column specifications must be separated by commas.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Dec 05, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 11, 2013
    Quiz Created by
    Moxleyv

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.