SAS Chapter 13: Creating Samples And Indexes

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,900
Questions: 10 | Attempts: 124

SettingsSettingsSettings
SAS Chapter 13: Creating Samples And Indexes - Quiz


Practice for the SAS advance certification exam.


Questions and Answers
  • 1. 

    The variable that is created by the POINT= option is assigned a value

    • A.

      Automatically during compilation of the DATA step.

    • B.

      Automatically during execution of the DATA step.

    • C.

      During compilation of the DATA step, by program statements.

    • D.

      During execution of the DATA step, by program statements.

    Correct Answer
    D. During execution of the DATA step, by program statements.
    Explanation
    The POINT= option in the SET statement names a variable. You must use program statements to assign a value to this variable during execution of the DATA step, before execution of the SET statement. Also, the value of the POINT= variable should be a number that corresponds to an observation number in the input data set, and it should be different each time the SET statement executes.

    Rate this question:

  • 2. 

    Which of the following programs correctly creates a systematic sample from a data set with an unknown number of observations and outputs these sample observations to a data set named Sample?

    • A.

      data sample; set sasuser.sale2000 point=thisone nobs=totnum; output; stop; run;

    • B.

      data sample; do thisone=100 to totnum by 100; set sasuser.sale2000 point=thisone nobs=totnum; output; end; stop; run;

    • C.

      data sample; do thisone=100 to 1000 by 100; set sasuser.sale2000 point=thisone; output; end; stop; run;

    • D.

      data sample; do thisone=100 to totnum by 100; set sasuser.sale2000 point=thisone nobs=totnum; end; run;

    Correct Answer
    B. data sample; do thisone=100 to totnum by 100; set sasuser.sale2000 point=thisone nobs=totnum; output; end; stop; run;
    Explanation
    To create a systematic sample from a data set that has an unknown number of observations, you use the NOBS= option in conjunction with the POINT= option in the SET statement. The NOBS= variable is automatically assigned a value of the total number of observations in the input data set, and you must assign a value to the POINT= variable before the SET statement executes.

    Rate this question:

  • 3. 

    Which of the following expressions will generate a random integer between 1 and 50?

    • A.

      Ceil(ranuni(50))

    • B.

      Ranuni(50)

    • C.

      Ceil(ranuni(0)*50)

    • D.

      Ceil(ranuni(0))*50

    Correct Answer
    C. Ceil(ranuni(0)*50)
    Explanation
    In order to create a random sample of a data set, you need to generate a random integer. You can use the RANUNI function in conjunction with the CEIL function to create a random integer. You can use a multiplier with the RANUNI function to increase the range from which the random number is chosen to include as many numbers as you need.

    Rate this question:

  • 4. 

    An index

    • A.

      Is an optional file that is associated with a data set.

    • B.

      Provides direct access to specific observations of a data set, based on the value of one or more key variables.

    • C.

      Can be classified as simple or composite, either of which can consist of unique values.

    • D.

      All of the above

    Correct Answer
    D. All of the above
    Explanation
    An index is a separate file from a data set that contains information about observations within the data set. Specifically, an index contains value/identifier pairs that indicate the location of observations within the data set and the value of one or more key variables in that observation.

    Rate this question:

  • 5. 

    Which of the following correctly creates a data set named Flights from the Sasuser.Revenue data set, creates a composite index namedFromto that is based on the values of Origin and Dest, and prints informational messages about the index to the SAS log?

    • A.

      options msglevel=i; data flights index=(Fromto=origin dest); set sasuser.revenue; run;

    • B.

      options msglevel=n; data flights (index=(Fromto=origin dest)); set sasuser.revenue; run;

    • C.

      options msglevel=i; data flights (index=(Fromto=(origin dest))); set sasuser.revenue; run;

    • D.

      options msglevel=n; data flights (index=Fromto); set sasuser.revenue; run;

    Correct Answer
    C. options msglevel=i; data flights (index=(Fromto=(origin dest))); set sasuser.revenue; run;
    Explanation
    To create an index at the same time that you create a data set, you use the INDEX= option in the DATA statement. You must assign a unique name to a composite index, while a simple index is automatically assigned the name of the key variable as its name. You can set the value of the MSGLEVEL= system option to I in order to see messages about indexes in the SAS log.

    Rate this question:

  • 6. 

    Which of the following is true?

    • A.

      When you add observations to a data set, the index(es) are automatically updated with additional value/identifier pairs.

    • B.

      When you rename a variable that is used as the key variable in a simple index, you must re-create the index.

    • C.

      When you delete a data set, the index file remains until you delete it as well.

    • D.

      When you copy a data set with the COPY statement, you must also copy the index file in another step.

    Correct Answer
    A. When you add observations to a data set, the index(es) are automatically updated with additional value/identifier pairs.
    Explanation
    For many maintenance tasks that you perform on a data set, SAS automatically performs corresponding tasks to the index file. For example, if you delete a data set, the index file is deleted as well. If you rename a data set with the CHANGE statement in the DATASETS procedure, SAS automatically renames the index file. If you copy a data set to a new location with the COPY statement in the DATASETS procedure, SAS automatically reconstructs the index file in the new location.

    Rate this question:

  • 7. 

    To create an index on an existing data set, you use

    • A.

      PROC DATASETS.

    • B.

      PROC SQL.

    • C.

      The DATA step with the INDEX= option, to rebuild the data set.

    • D.

      Any of the above

    Correct Answer
    D. Any of the above
    Explanation
    You can use the DATASETS procedure or the SQL procedure to create an index on or delete an index from an existing data set. You can also rebuild the index with a DATA step and use the INDEX= option to create an index on the rebuilt data set. However, rebuilding a data set uses more system resources than adding an index to an existing data set with either the DATASETS or the SQL procedure.

    Rate this question:

  • 8. 

    Which of the following correctly creates a simple index named Origin on the Revenue data set?

    • A.

      proc sql; create index origin on revenue(origin); quit;

    • B.

      proc sql; modify revenue; index=origin; quit;

    • C.

      proc sql data=revenue; create index origin; quit;

    • D.

      proc sql; index=origin on revenue; quit;

    Correct Answer
    A. proc sql; create index origin on revenue(origin); quit;
    Explanation
    You use the CREATE INDEX statement of the SQL procedure to create an index on an existing data set. In the SQL procedure, you must name the index in the CREATE INDEX statement; for a simple index, the index name must match the name of the key variable.

    Rate this question:

  • 9. 

    To view a list of the indexes that are associated with a data set, you use

    • A.

      PROC COPY or the COPY statement in PROC DATASETS.

    • B.

      PROC CONTENTS or the CONTENTS statement in PROC DATASETS.

    • C.

      The MSGLEVEL= system option and a PROC PRINT step.

    • D.

      Any of the above

    Correct Answer
    B. PROC CONTENTS or the CONTENTS statement in PROC DATASETS.
    Explanation
    You can use either the CONTENTS procedure or the CONTENTS statement in the DATASETS procedure to generate a list of information about a data set, including a list of existing indexes. All indexes for a data set are stored in a single file that is separate from but has the same name as the data set.

    Rate this question:

  • 10. 

    Suppose that the Sasuser.Revenue data set has a simple index named FlightID. For which of the following programs will the index be used?

    • A.

      proc print data=sasuser.revenue; where flightid ne 'IA11200'; run;

    • B.

      data someflights; set sasuser.revenue; where flightid > 'IA11200'; run;

    • C.

      data someflights; set sasuser.revenue; if flightid > 'IA11200'; run;

    • D.

      proc print data=sasuser.revenue; where origin='RDU' or flightid='IA03400'; run;

    Correct Answer
    B. data someflights; set sasuser.revenue; where flightid > 'IA11200'; run;
    Explanation
    An index can improve the efficiency with which SAS is able to access certain observations in a data set. However, an index is not always useful. SAS will not use an index to process subsetting IF statements, or other statements that SAS determines might be more efficiently processed without an index.

    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 14, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 26, 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.