Chapter 7: Creating And Managing Views 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: 21,003
Questions: 10 | Attempts: 122

SettingsSettingsSettings
SQL Quizzes & Trivia

Practice for the SAS advance certification exam.


Questions and Answers
  • 1. 

    Which of the following statements is false regarding a PROC SQL view?

    • A.

      A view cannot be used in a join.

    • B.

      A view accesses the most current underlying data.

    • C.

      A view follows the same naming conventions as a table.

    • D.

      A view can be used in SAS programs in place of an actual SAS data file.

    Correct Answer
    A. A view cannot be used in a join.
    Explanation
    A PROC SQL view accesses the most current underlying data and can be joined with tables or other views. In addition, a PROC SQL view can

    be used in SAS programs in place of an actual SAS data file

    be derived from one or more tables, PROC SQL views, or DATA step views.

    Rate this question:

  • 2. 

    Which of the following statements describes an advantage of using a PROC SQL view?

    • A.

      Views often save space, because a view is usually quite small compared with the data that it accesses.

    • B.

      Views prevent users from continually submitting queries to omit unwanted columns or rows.

    • C.

      Views hide complex joins or queries from users.

    • D.

      All of the above

    Correct Answer
    D. All of the above
    Explanation
    PROC SQL views are useful because they

    often save space (a view is usually quite small compared with the data that it accesses)

    prevent users from continually submitting queries to omit unwanted columns or rows

    hide complex joins or queries from users.

    In addition, PROC SQL views

    ensure that input data sets are always current, because data is derived from tables at execution time

    can be used to shield sensitive or confidential columns from users while enabling the same users to view other columns in the same table.

    Rate this question:

  • 3. 

    Which PROC SQL step creates a view that queries the table Sasuser.Payrollmaster?

    • A.

      proc sql; insert into sasuser.newview select * from sasuser.payrollmaster;

    • B.

      proc sql; create sasuser.newview as select * from sasuser.payrollmaster;

    • C.

      proc sql; create view sasuser.newview as select * from sasuser.payrollmaster;

    • D.

      proc sql; select * from sasuser.payrollmaster into view sasuser.newview;

    Correct Answer
    C. proc sql; create view sasuser.newview as select * from sasuser.payrollmaster;
    Explanation
    You use the CREATE VIEW statement to create a view. The keywords CREATE VIEW are followed by the name of the view and the keyword AS.

    Rate this question:

  • 4. 

    Which of the following PROC SQL steps enables you to see a description of the view definition?

    • A.

      proc sql; select * from sasuser.payrollmasterv;

    • B.

      proc sql; describe view sasuser.payrollmasterv;

    • C.

      proc sql; list sasuser.payrollmasterv;

    • D.

      proc sql; contents view=sasuser.payrollmasterv;

    Correct Answer
    B. proc sql; describe view sasuser.payrollmasterv;
    Explanation
    The DESCRIBE VIEW statement displays the view definition in the SAS log.

    Rate this question:

  • 5. 

    Which PROC SQL step correctly references the view Data.Empview?

    • A.

      proc sql; select * from data.empview;

    • B.

      proc sql; select * from view data.empview;

    • C.

      proc sql; select view * from data.empview;

    • D.

      proc sql; select * from data where view='empview';

    Correct Answer
    A. proc sql; select * from data.empview;
    Explanation
    A view can be used in a PROC SQL step just as you would use an actual SAS table.

    Rate this question:

  • 6. 

    Which of the following PROC SQL steps correctly embeds a LIBNAME statement with a view definition?

    • A.

      proc sql; insert into sasuser.newview select * from airline.supervisors libname airline 'c:\mysql';

    • B.

      proc sql; create view sasuser.newview as from airline.supervisors embed libname airline 'c:\mysql';

    • C.

      proc sql; using airline 'c:\mysql'; insert into sasuser.newview select * from airline.supervisors;

    • D.

      proc sql; create view sasuser.newview as select * from airline.supervisors using libname airline 'c:\mysql';

    Correct Answer
    D. proc sql; create view sasuser.newview as select * from airline.supervisors using libname airline 'c:\mysql';
    Explanation
    The USING clause enables you to embed a LIBNAME statement in your view definition. The USING clause must be the last clause in the CREATE VIEW statement.

    Rate this question:

  • 7. 

    PROC SQL views can access data from

    • A.

      A SAS data file.

    • B.

      Another PROC SQL view.

    • C.

      A relational database table.

    • D.

      All of the above

    Correct Answer
    D. All of the above
    Explanation
    PROC SQL views can access data from a SAS data file, a DATA step view, a PROC SQL view, or a relational database table.

    Rate this question:

  • 8. 

    When you are working with PROC SQL views, it is best to

    • A.

      Avoid using an ORDER BY clause in a view.

    • B.

      Avoid creating views that are based on tables whose structure might change.

    • C.

      Specify a one-level name in the FROM clause if the view resides in the same SAS data library as the contributing table(s).

    • D.

      All of the above

    Correct Answer
    D. All of the above
    Explanation
    When you are working with PROC SQL views, it is best to

    avoid using an ORDER BY clause in a view. If you specify an ORDER BY clause, the data must be sorted each time the view is referenced.

    avoid creating views that are based on tables whose structure might change. A view is no longer valid when it references a nonexistent column.

    specify a one-level name in the FROM clause if the view resides in the same SAS data library as the contributing table(s). Using a one-level name in the FROM clause prevents you from having to change the view if you assign a different libref to the SAS data library that contains the view and its contributing table or tables.

    Rate this question:

  • 9. 

    You can update the data underlying PROC SQL view using the INSERT, DELETE, and UPDATE statements under which of the following conditions:

    • A.

      The view is joined or linked to another table.

    • B.

      The view contains a subquery.

    • C.

      The view contains a WHERE clause.

    • D.

      All of the above

    Correct Answer
    C. The view contains a WHERE clause.
    Explanation
    You can update a PROC SQL view provided that the view does not join or link to another table, the view does not have a subquery, or you try to update a derived column. You can update a view that contains a WHERE clause. The WHERE clause can be in the UPDATE clause or in the view. You cannot update a view that contains any other clause such as an ORDER BY or a HAVING clause.

    Rate this question:

  • 10. 

    Which of the following programs drops (deletes) a view?

    • A.

      proc sql; delete sasuser.newview;

    • B.

      proc sql; drop view sasuser.newview;

    • C.

      proc sql; erase view sasuser.newview;

    • D.

      proc sql; remove newview from sasuser;

    Correct Answer
    B. proc sql; drop view sasuser.newview;
    Explanation
    The DROP VIEW statement drops a view from the specified library.

    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
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 13, 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.