You are on page 1of 3

MGMT635 Assignment 2 (20 points)

1. Joining Data from Two Tables (5 points)


Use the New Query Builder to create a new table whose data results from a join of two tables. Create
a new column.
a. Use the New Query Builder to join employee_payroll and employee_addresses to create a table
named payroll_location.
b. Make sure that the join between the two tables is on the Employee_ID column.
c. Include the following columns on the Select Data tab: Employee_ID, Employee_Name,
Employee_Gender, Birth_Date, Salary, Street_Number, Street_Name, City, State,
Employee_Term_Date, and Country.
d. Click on Properties tab. Set the output location to MGMT635 and output name to be
payroll_location.
e. Run the new query. Provide the screenshots of the results and use complete sentences to describe
the attributes of payroll_location data set.
f. Write a SAS program for parts g through k below. Name the output file payroll_location_1.
g. Format the Salary column with a dollar sign, comma, width 12, and two decimal places.
h. Create a new column named Bonus that represents 1.5% of the Salary column. Format the values
with a dollar sign, comma, and two decimal places.
i. Create New_Salary, which is the current salary plus an additional 2% raise. Format the values
with a dollar sign, comma, and two decimal places.
j. Include only active employees in the output table. In other words, include only employees who
have a missing value for Employee_Term_Date.
k. Insert drop employee_term_date; directly before the RUN statement.
l. Run the code and view the results. Save the program in the SAS Code folder as Location.sas.
Provide the screenshots of the results and use complete sentences to describe the attributes of
payroll_location_1 data set.
Use a SAS Data step and not a Proc step for the remaining exercises.
2. Creating a Calculated Column Using a Function (3 points)
Create a table from the employee_donations table with a new column that indicates the total
contributions from each employee.
a. Open the employee_donations SAS data set.
b. Write a SAS program to create a table named mgmt635.donations.
c. Create a new column named Total_Donations, which totals the values of the four quarterly
donations. Format the new column to display dollar signs, commas, width 12, and two decimal
places.
 Use a function to calculate the total, thereby ignore any missing values that might be in
the input columns.
d. Include the Employee_ID, Recipients, Paid_By, and Total_Donations columns in the new
table.
e. Run the program. Save the program in the SAS Code folder as Donations.sas.
Provide the screenshot of mgmt635.donations table.

3. Creating a Program to Calculate the Number of Years Employed (4 points)


Write a SAS program to create a table named years_at_work in the MGMT635 folder that includes
active employees (those with no termination date) and the number of years that each has been
employed until December 10, 2020.
a. Use the Employee_Payroll table as the input table. Include Employee_ID and
Employee_Hire_Date. Include only employees without a termination date.
b. Create a new column named Years_Employed that calculates the number of years that each
employee worked at Orion Star, based on the hire date and December 10, 2020. Apply a format
that displays the values rounded to one decimal place.
Hint: The function YRDIF(start-date, end-date, ‘actual’) computes the years. The start-date is
Employee_Hire_Date. The end-date is December 10, 2020 expressed as a date constant.
For example, March 1, 2022 should be entered as '1Mar2022'd
The format of the new column is 4.1.
c. Run the program and verify the results. Save the program to the SAS Code folder as
Howlong.sas. Provide the screenshot of the years_at_work table and use complete sentences to
describe the attributes of this table.
d. Use the Characterize Data task to investigate the distribution of Years_Employed in the
years_at_work table. Provide the screenshot of the results, i.e. descriptive statistics and
distribution of Years Employed. Write a few lines about the distribution of Years Employed.
* For additional information on YRDIF function, please visit the webpage at
http://documentation.sas.com/?
docsetId=ds2ref&docsetTarget=n18y49sva4majan124os3wch827a.htm&docsetVersion=3.1&locale=e
n
4. Creating a New Column by Recoding Distinct Values (4 points)
The Country column in the employee_addresses table includes country codes, such as US
and AU. Write SAS program that includes a new column, named Country_Name, that recodes the
values US and AU to the full country name. [Hints: 1) Pay attention to the length of Country_Name
column. 2) Use if upcase(Country) = “US” then… ; else if … then; else…; statement. 3) Pay attention
to the issue of letter case and missing values. You could use upcase(Country) to convert the values of
Country into uppercase strings. If Country information is missing for an observation, you could let
Country_Name = “Missing” or Country_Name = “”]
a. Create a table named mgmt635.country_name. Name the SAS program Country_name.sas and
store in the SAS Code folder.
b. Provide a screenshot of table mgmt635.country_name.
3

5. Creating a New Column by Recoding Ranges of Values (4 points)


Write a SAS program to create a new column that groups salary values into four categories. Name the
new column Salary_Range. Recall that Salary is in mgmt635.employee_payroll.
a. Create a table named mgmt635.Salary_Range.
b. Create a new column named Salary_Range based on the values in the Salary column.

0 – 24999.99 Below $25K

25000 – 49999.99 $25K to $50K

50000 – 99999.99 $50K to $100K

100000 and above Over $100K

c. Format Employee_Hire_Date with the DDMMYY10. format so that dates appear as 20/10/2008.
d. Include only the Employee_ID, Salary, Employee_Hire_Date, and Salary_Range columns.
e. Run the program. Save the program in the SAS Code folder as SalaryRange.sas. Provide a
screenshot of table mgmt635.Salary_Range.

Deliverables:
Step 1: Include all your answers to problems 1 to 5 in a Word document and turn in the Word document via Canvas.
Please also insert the SAS codes you wrote, i.e. codes in Location.sas, Donations.sas, Howlong.sas,
Country_name.sas and SalaryRange.sas, into the same word document.

Step 2: Use the information in the Word document to take the Assignment 2 quiz in Canvas.
*Assignment 2 quiz score will be counted as your overall score for assignment 2. Assignment 2 quiz score will be
reduced by up to 5 points if a student does not submit the Word document showing answers to problems 1 to 5. An
instructor or TA will check the Word documents you submit through the Assignment 2 upload link in Canvas and
make the adjustment.

You might also like