*********************************************************************;
*Question 1 (20 pts);
**** For the two datasets below,
1a. use a data step to merge, and
1b. use a PROC sql to join.
1c. Do you get the same results? If no, update your proc sql to make the result the same;
;
data one;
input x $;
datalines;
cat
catnap
catnip
;
data two;
input x $3. y ;
datalines;
cat 111
dog 222
;
*Q2: bookstore datasets from Canvas classroom.
*Q2a (15 pts) – Check the variables contained in each individual data table below:
customers, items, list, orders, prices and salesrep.
The purpose of this exercise is to identify the match keys across the data sets for merging.
create a dataset that stores the list of variable names in each table. Each column lists the
variable names for one dataset. e.g. a column called customers with values being the variable
names of the dataset customers.
hint: use the option OUT= in PROC CONTENTS to save dataset information in another dataset for
additional processing.;
*Q2b (15 pts) – Create a table using PROC SQL to join the tables orders, items, and list, and
* –include all columns from orders, the author and bookid columns from list;
* –Include only rows that match across all three data sets , and
* –Create a variable YEARSOLD for the year that the books was ordered;
*Q2c(10 pts) in Q2b above, all the requested columns are available in two tables: orders and list.
Can you join only these two tables without the third table items? why or why not?;
*Q2d(15 pts) – Join the data sets orders and customers containing only the order numbers between
45520 and 45570;
* — include all vars in the ORDERS table;
* — include no variables from the customers table, and
* — add a variable containing the name of the customer as “first name, exactly one space,
last name”. e.g. John Smith;
*Q2e(15 pts) – Join the data to create a table including the variables
order number,
date shipped,
ID of the sales rep and
last name of sales rep. ;
*Q2f(10 pts) – use the table you created in Q2e above, use PROC SQL step(s) to figure out which rep
sold the most;