0% found this document useful (0 votes)
60 views7 pages

Practical No 6 A082

The document describes 3 assignments for a practical on creating reports from Excel files and customizing SAS data sets. Assignment 1 involves reading an existing SAS data set, creating a new variable by adding 10% to salaries for females, and adding labels and formats. Assignment 2 requires selecting observations from an order data set where delivery dates are late and for a specific employee and month, and adding labels and formats. Assignment 3 involves reading an Excel worksheet into a SAS data set after subsetting for specific country and customer type, keeping selected variables, and adding a format and labels before clearing the Excel libref.

Uploaded by

Juee Jamsandekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views7 pages

Practical No 6 A082

The document describes 3 assignments for a practical on creating reports from Excel files and customizing SAS data sets. Assignment 1 involves reading an existing SAS data set, creating a new variable by adding 10% to salaries for females, and adding labels and formats. Assignment 2 requires selecting observations from an order data set where delivery dates are late and for a specific employee and month, and adding labels and formats. Assignment 3 involves reading an Excel worksheet into a SAS data set after subsetting for specific country and customer type, keeping selected variables, and adding a format and labels before clearing the Excel libref.

Uploaded by

Juee Jamsandekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Practical No.

6
Aim: To create reports from excel files, read and customize SAS data sets

Prerequisite:

1. Understanding of fundamental programming constructs of Base SAS

Outcome: After successful completion of this experiment students will be able to

1. Use a Set command to read from an existing SAS data set.


2. Creation of a new variable using assignments statements.
3. Using Label and Format statements in the DATA step.

(TO BE COMPLETED BY STUDENTS)

Roll No. A082 Name: Ankita jha


Class: Btech IT Batch: A2
Date of Practical:9/2/24 Date of Submission:9/2/24
Grade:

Assignment 1:

For the following program

Proc print data=orion.au_salesforce;


Run;

Write a DATA step to create a new data set named work.assistant. use the data set
orion.au_salesforce as input.
The work.assistant data set should contain observations where gender is Female
Create a new variable New_salary which is Salary +Salary multiplied by 0.10
Add the following permanent labels:
New_Salary: New Annual Salary
Salary: Employee Annual Salary
Add permanent format to display new_salary using dollar 10.2 format
Work.assistant should contain only employee_id,gender, Salary, New_salary and job_title.

Code of the program:

proc print data=oriona2.au_salesforce;

run;
data work.assistant;

set oriona2.au_salesforce;

where Gender='F';

New_Salary= Salary+Salary*0.10;

label New_Salary='New Annual Salary'

Salary= 'Employee Annual Salary';

format new_salary dollar10.2;

drop First_Name Last_Name Country Birth_Date Hire_Date;

run;

proc print data=work.assistant label;

run;

Output of the Program:


Assignment 2:

Write a DATA step to create work.delays. use orion.orders as input.


Create a new variable, order_month and set it to month of order_date (use MONTH function).
Use a WHERE statement and a subsetting IF statement to select observations as indicated below.
a. Delivery_date values that are more than four days beyond order_date.
b. Employee_id values that are equal to 99999999
c. Order_month values occurring in August
New data set should contain only employee_id, customer_id, order_date,delivery_date and
order_month.
Add permanent labels and formats as shown below.
Order_date – Date ordered, MM/DD/YYYY
Delivery_date – Date delivered, DATE format.

Add PROC CONTENTS to display the descriptor portion of the data set.
Code of the program:

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';

format Order_Date mmddyy10. Delivery_Date date9.;

run;

proc print data=work.delays label;

run;

proc contents data=work.delays;

run;

Output of the Program:


Assignment 3:

For the following program

options validvarname=any;

Write a LIBNAME statement after the OPTIONS statement to create a libref named custfm that
references the excel workbook custfm_N.xlsx. (use xlsx as the engine). Display the worksheets
in the libref created.
Create a data set named subsetFemale using Data step by reading from the ‘Female’ worksheet
of the custfm_N file. The data set should contain only records with country being ‘US’ and
customer type to have only ‘Orion club Gold members’.
Add a KEEP statement to include only First_name, Last-name and Birth_Date in the new data
set.
Add a FORMAT statement in the DATA step to display Birth_date as a four-digit year
Add a LABEL statement in the DATA step to display Birth year instead of Birth_Date and
FName instead of First_Name and Lname instead of Last_name
Add a LIBNAME statement to the program to clear the libref.

Code:

libname custfm xlsx "/home/u63715849/Ankita/custfm_N.xlsx";

data work.subsetFemale;

set custfm.females;

where Country="US" and Customer_Type LIKE "Orion Club Gold members%";

keep First_Name Last_Name Birth_Date;

format Birth_Date year4.;

label Birth_Date='Birth Year' First_Name='FName' Last_Name='LName';

run;

proc print data=work.subsetFemale label;

run;

libname custfm clear;


output:

******************************

You might also like