Fundamentals of Programming in SAS. James Blum

Чтение книги онлайн.

Читать онлайн книгу Fundamentals of Programming in SAS - James Blum страница 13

Автор:
Жанр:
Серия:
Издательство:
Fundamentals of Programming in SAS - James Blum

Скачать книгу

as one of the files included with the text: CustomSapphire.sas. It is designed to store the CustomSapphire template in the BookData library in a template store named Template (which can be changed in the STORE= option in the DEFINE statement in the provided code). If the BookData library is assigned, submitting the CustomSapphire.sas code creates the template in that library. To use the template, two items are required. First, an ODS statement must be submitted to direct SAS to look for templates at this location, such as:

      ods path (prepend) BookData.Template;

      The ODS PATH includes a list of template stores that SAS searches whenever a request for a template has been made. Since multiple stores may have templates with the same name, the sequence matters, so the PREPEND option ensures the listed stores are at the start of the list (with the possible exception of the default template store in the WORK library). To see the current template stores listed in the path, submit the statement:

      ods path show;

      The template store(s) named in other ODS PATH statements appear in this list shown in the SAS log if they were correctly assigned. These two statements appear in the code given for every chapter of this book.

      To see a list of templates available in any template store, a variation on the PROC TEMPLATE code given in Chapter Note 8 is given.

      proc template;

      list / store=BookData.Template;

      run;

      Finally, to use the style template with any ODS file destination (assuming all previous steps are functional), use STYLE=CustomSapphire, similar to the use of STYLE=Journal in Program 1.5.4.

      10. Valid Variable and Other Names. For most of the activities in this book, the naming conventions described in Section 1.6.2 apply. However, since SAS can connect to other data sources have different naming conventions, there are times when it is advantageous to alter these conventions. The VALIDVARNAME= system option allows for different rules to be enacted for variable names, while the VALIDMEMNAME= option allows for altering the naming conventions for data sets and data views. These are taken up in Section 7.6, which covers connections to Microsoft Excel workbooks and Access databases, which have different naming conventions than SAS.

      Concepts: Multiple Choice

      1. Using the default rules for naming in SAS, which of the following is a valid library reference?

      a. ST445Data

      b. _LIB_

      c. My-Data

      d. 445Data

      2. Which of the following is not a syntax error?

      a. Misspelling a keyword like PROC as PORC

      b. Misspelling a variable name like TypeB as TypB

      c. Omitting a semicolon at the end of a RUN statement

      d. Forgetting to close the quotation marks around the path in the LIBNAME statement

      3. Which of the following is a temporary data set?

      a. Work.Employees

      b. Employees.Work

      c. Temp.Employees

      d. Employees.Temp

      4. Using the default rules for naming data sets in SAS, which of the following cannot be used when naming a data set?

      a. Capital letters

      b. Digits

      c. Dashes

      d. Underscores

      5. What statement is necessary to produce the following information?

      Output Added:

      -------------

      Name: Report

      Label:

      Data Name: ProcReportTable

      Path: Report.Report.Report

      a. ODS RTF;

      b. ODS PDF;

      c. ODS TRACE ON;

      d. ODS LISTING;

      Concepts: Short Answer

      1. Under standard SAS naming conventions, decide whether each of the following names is legal syntax when used as a:

      i. Library reference

      ii. Data set name

      iii. Variable name

       Provide justification for each answer.

      a. mydata

      b. myvariable

      c. mylibrary

      d. left2right

      e. left-2-right

      f. house2

      g. 2nd_house

      h. _2nd

      2. Classify each of the following statements as: always true, sometimes true, or never true. Provide justification for each answer.

      a. An error message in the log is an indication of a syntax error.

      b. A warning message in the log is an indication of a logic error.

      c. Notes in the log provide details about successful code execution.

      d. Checking the log only for errors and warnings is considered a good programming practice.

      3. Classify each of the following statements as: always true, sometimes true, or never true. Provide justification for each answer.

      a. SAS data sets can contain only numeric and character variables.

      b. If the library is omitted from a SAS data set reference, the Work library is assumed.

      c. Once a library is assigned in a SAS session, it is available automatically in subsequent SAS sessions on that machine.

      d. A library and a data set can have the same name.

      4. Classify each of the following statements as: always true, sometimes true, or never true. Provide justification for each answer.

      a. A PROC step can be nested with a DATA step.

      b. The RUN statement must be used as a step boundary at the end of a DATA or PROC step.

      c. It is a good programming practice to use an explicit step boundary, such as the RUN statement, at the end of any DATA or PROC step.

      d.

Скачать книгу