B1 Exercise Chapter 6
B1 Exercise Chapter 6
LEVEL 1
a) Costumer_gender
F, M
data work.youngadult;
set orion.customer_dim;
Discount = 0.25;
run;
data work.assistant;
set orion.staff;
where job_title contains 'Assistant' and salary < 26000;
increase = salary * 0.10;
new_salary = salary + increase;
run;
LEVEL 1
data work.increase;
set orion.staff;
Increase=Salary*0.10;
NewSalary=Salary+Increase;
where emp_hire_date >= '01Jul2010'd ;
if Increase >3000;
keep employee_id emp_hire_date Salary Increase NewSalary;
label emp_hire_date ='Hire Date'
employee_id='Employee ID'
NewSalary='New Annual Salary'
Salary='Employee Annual Salary';
format emp_hire_date date9.
employee_id 12.
Increase comma5.
NewSalary Salary dollar10.2;
run;
proc contents data=work.increase;
run;
In the SAS program you provided, some variables in the work.subset1 dataset have labels and formats
that were not explicitly defined in the program. In SAS, labels and formats can be inherited from the
input dataset or from a previously defined format or label.
When a SAS dataset is created using a SET statement, the dataset inherits the variable attributes
(including labels and formats) from the input dataset. In this case, the work.subset1 dataset inherits
the labels and formats from the orion.sales dataset.
libname orion "C:\Users\NIsaHumaira\OneDrive\Desktop\ICT
IV\DEGREE(4)\STA610\P1 2017 Data\P1 2017 Data";
data work.increase;
set orion.staff;
Increase=Salary*0.10;
NewSalary=Salary+Increase;
where emp_hire_date >= '01Jul2010'd ;
if Increase >3000;
keep employee_id emp_hire_date Salary Increase NewSalary;
label emp_hire_date ='Hire Date'
employee_id='Employee ID'
NewSalary='New Annual Salary'
Salary='Employee Annual Salary';
format emp_hire_date date9.
employee_id 12.
Increase comma5.
NewSalary Salary dollar10.2;
run;
proc contents data=work.increase;
run;
proc print data=work.increase split=' ';
run;
LEVEL 2
libname orion "C:\Users\NIsaHumaira\OneDrive\Desktop\ICT
IV\DEGREE(4)\STA610\P1 2017 Data\P1 2017 Data";
data work.delays;
set orion.orders;
order_month=month(order_date);
where delivery_date - order_date > 4;
if employee_id=99999999 and order_month=8;
keep employee_id customer_id order_date delivery_date order_month;
label order_date ='Date Ordered'
delivery_date='Date Delivered'
order_month='Month Ordered';
format order_date delivery_date mmddyy10.;
run;
run;
proc contents data=work.delays;
run;