Chapter 1: Performing Queries 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: 583

SettingsSettingsSettings
Chapter 1: Performing Queries Using Proc SQL - Quiz

Structured Query Language is a domain-specific language used in programming and designed for managing data held in a relational database management system or for stream processing in a relational data stream management system. Do you understand how to perform queries using proc SQL? Take up the quiz blow and get to review what you learn it Chapter 1 in preparation for the advanced SAS certification exam that is coming up.


Questions and Answers
  • 1. 

    Which of the following clauses in the PROC SQL program below is written incorrectly? proc sql; select style sqfeet bedrooms from choice.houses where sqfeet ge 800;

    • A.

      SELECT

    • B.

      FROM

    • C.

      WHERE

    • D.

      Both a and c

    Correct Answer
    A. SELECT
    Explanation
    The SELECT clause in the program is written incorrectly. Columns that are listen in the clause must be separated by commas, not just blanks.

    Rate this question:

  • 2. 

    How many statements does the program below contain? proc sql; select grapes, oranges, grapes + oranges as sumsales from sales.produce order by sumsales;

    • A.

      Two

    • B.

      Three

    • C.

      Four

    • D.

      Five

    Correct Answer
    A. Two
    Explanation
    There are two statements, the PROC SQL statement and the SELECT statement. The SELECT statement contains three clauses.

    Rate this question:

  • 3. 

    Complete the following PROC SQL query to select the columns Address and SqFeet from the table List.Size and to select Price from the table List.Proce. (Only the Address column appears in both tables.) proc sql; ___________ where size.address = price.address; from list.size, list.price;

    • A.

      Select address, sqfeet, price

    • B.

      Select size.address, sqfeet, price

    • C.

      Select price.address, sqfeet, price

    • D.

      Either B or C

    Correct Answer
    B. Select size.address, sqfeet, price
    Explanation
    The SELECT clause lists the columns from both tables to be queried. You must use a prefix with the Address column because it appears in both tables. The prefix specifies the table from which you want the column to be read.

    Rate this question:

  • 4. 

    Which of the clauses below correctly sorts rows by the values of the columns Price and SqFeet?

    • A.

      Order price, sqfeet

    • B.

      Order by price, sqfeet

    • C.

      Sort by price sqfeet

    • D.

      Sort price sqfeet

    Correct Answer
    B. Order by price, sqfeet
    Explanation
    The ORDER BY clause specifies how the rows are to be sorted. You follow the keywords ORDER BY one or more column names or numbers, separated by columns.

    Rate this question:

  • 5. 

    Which clause below specifies that the two tables Produce and Hardware be queried? Both tables are located in a library to which the libref Sales has been assigned.

    • A.

      Select sales.produce sales.hardware

    • B.

      From sales.produce sales.hardware

    • C.

      From sales.produce, sales.hardware

    • D.

      Where sales.produce, sales.hardware

    Correct Answer
    C. From sales.produce, sales.hardware
    Explanation
    In the FROM clause, you list the names of the tables to be queried, separated by commas.

    Rate this question:

  • 6. 

    Complete the SELECT clause below to create a new column named Profit by subtracting the values of the column Cost from those of the column Price. select fruit,cost,price, _____________

    • A.

      Profit=price-cost

    • B.

      Price-cost as Profit

    • C.

      Profit= price-cost

    • D.

      Profit as price-cost

    Correct Answer
    B. Price-cost as Profit
    Explanation
    To create a new column and assign a column alias to the column, you specify the following in the SELECT clause, in the order shown here: an expression, (optionally) the keyword AS, and column alias. The case that you use when you create the column name is the one that will be displayed in the output.

    Rate this question:

  • 7. 

    What happens if you use a GROUP BY clause in a PROC SQL step without a summary function?

    • A.

      The step does not execute.

    • B.

      The first numeric column is summed by default.

    • C.

      The GROUP BY clause is changed to an ORDER BY clause

    • D.

      The step executes but does not group or sort data.

    Correct Answer
    C. The GROUP BY clause is changed to an ORDER BY clause
    Explanation
    The GROUP BY clause is used in queries that include one or more summary functions. If you specify a GrOUP BY clause in a query that does not contain a summary function, it is changed to an ORDER BY clause.

    Rate this question:

  • 8. 

    If you specify a CREATE TABLE statement in your PROC SQL step,

    • A.

      the results of the query are displayed, and a new table is created.

    • B.

      A new table is created, but it does not contain any summarization that was specified in the PROC SQL step.

    • C.

      A new table is created, but no report is displayed.

    • D.

      Results are grouped by the value of the summarized column.

    Correct Answer
    C. A new table is created, but no report is displayed.
    Explanation
    The CREATE TABLE statement enables you to store your results in a SAS table instead of displaying the query results as a report.

    Rate this question:

  • 9. 

    Which statement is true regarding the use of the PROC SQL step to query data that is stored in two or more tables?

    • A.

      When you join multiple tables, the tables must contain a common column.

    • B.

      You must specify the table from which you want each column to be read.

    • C.

      The tables that are being joined must be from the same type of data source.

    • D.

      If two tables that are being joined contain a same-named column, thenn you must specify the table from which you want the column to be read.

    Correct Answer
    D. If two tables that are being joined contain a same-named column, thenn you must specify the table from which you want the column to be read.
    Explanation
    When using the PROC SQL step to query data from multiple tables, if there are two tables being joined that have a column with the same name, you must specify the table from which you want to retrieve the column. This is necessary to avoid any ambiguity and ensure that the correct column is selected from the appropriate table.

    Rate this question:

  • 10. 

    Which clause in the following program is incorrect? proc sql; select sex, mean(weight) as avgweight from company.employees company.health  where employees.id=health.id group by sex;

    • A.

      SELECT

    • B.

      FROM

    • C.

      WHERE

    • D.

      GROUP BY

    Correct Answer
    B. FROM
    Explanation
    Tables in the from statement must be separated by a comma (,)

    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 04, 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.