You are on page 1of 12

EXERCISE CHAPTER 5.

LEVEL 1
proc print data=orion.employee_payroll;
var employee_ID Salary Birth_Date Employee_Hire_Date;
format salary dollar11.2 birth_date mmddyy10. employee_hire_date date9.;
run;
LEVEL 2
libname orion "C:\Users\NIsaHumaira\OneDrive\Desktop\ICT
IV\DEGREE(4)\STA610\P1 2017 Data\P1 2017 Data";

title1 'US Sales Employees';


title2 'Earning Under $26,000';

proc print data=orion.sales noobs split='*';


var Employee_ID First_Name Last_Name Job_Title Salary Hire_Date;
where salary <= 26000 and country='US';
label First_Name='First*Name'
Last_Name='Last Name'
Job_Title='Title'
Hire_Date='Date*Hired';
format Salary dollar7. Hire_Date monyy7.;
run;

title;
footnote;
CHALLENGE
libname orion "C:\Users\NIsaHumaira\OneDrive\Desktop\ICT
IV\DEGREE(4)\STA610\P1 2017 Data\P1 2017 Data";
proc print data=orion.sales noobs;
var employee_id first_name last_name job_title;
format first_name last_name $upcase9.
job_title $quote15.;
run;

- $UPCASEw.= Converts character data to uppercase.


- $quotew.= Writes data values that are enclosed in double quotation marks.
EXERCISE 5.2

LEVEL 1
libname orion "C:\Users\NIsaHumaira\OneDrive\Desktop\ICT
IV\DEGREE(4)\STA610\P1 2017 Data\P1 2017 Data";
data Q1Birthdays;
set orion.employee_payroll;
BirthMonth=month(Birth_Date);
if BirthMonth le 3;
run;
proc format;
value $gender 'F'='Female'
'M'='Male';
value mname 1='January'
2='February'
3='March';
run;
title 'Employees With Birthday in Q1';
proc print data= Q1Birthdays;
var employee_id employee_gender birthmonth;
format birthmonth mname. employee_gender $gender.;
run;
title;
LEVEL 2
proc print data=orion.nonsales;
var Employee_ID Job_Title Salary Gender;
format salary salrange. Gender $gender.;
title1 'Salary and Gender Values';
title2 'for Non-Sales Employees';
run;
proc format;
value $gender 'F'='Female'
'M'='Male'
other='Inalid code';

value salrange
20000 -< 100000 = 'Below $100000'
100000 -< 500000 = '$100000 or more'
. = 'Missing Salary'
other = 'Invalid Salary';
run;

title;
CHALLENGE

1. In SAS, the option that allows you to store a format in a permanent library is the CNTLOUT
option. The CNTLOUT option is used in conjunction with the PROC FORMAT statement to
specify the name and location of the catalog where the format will be stored.
2. The option that causes SAS to look for formats in a permanent library is the FMTSEARCH
option. The FMTSEARCH option allows you to specify a list of libraries to search for formats
when they are referenced in your SAS program.

You might also like