Scenario 6

Directions

This scenario uses the Certadv.Staff data set. Write a SAS program that does the following:
  • Define a macro variable named Job with a value of Analyst.
  • Use a DATA step to create a temporary data set Work.Staff from the data set Certadv.Staff. Within this DATA step, do the following:
    • Read in only those rows from the Certadv.Staff data set that contain the text specified in the macro variable Job.
    • Create a new column that keeps a running total of Salary. Code:Total+Salary;
    • Create a Count variable and increment its value by one for each observation. Code: Count+1;
    • Create a new macro variable named Avg. The value of Avg is the value of Total divided by the value of Count. Format Avg as DOLLAR9.
  • Use PROC PRINT to print Work.Staff. The output should include these elements:
    • a title with the value of the macro variable Job followed by the constant text 'Staff'.
    • a footnote with the constant text 'Average Salary:' followed by the value of the macro variable Avg.

Test Your Code

  1. What is the average salary?
  2. How many observations are printed?

Exam Objective

Create and use user-defined and automatic macro variables within the SAS macro language.
Last updated: October 16, 2019
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.45.253