Practical No 5 A082

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Practical No.

Aim: To create customized SAS data sets by reading from other existing 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.

(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:

Using the data set orion.customer_dim, write a DATA step to create a new data set named
work.youngadult. the new data set should contain only those observations in which customers
are female and their age should be between 18 to 36 years. Also the customers must have word
“Gold” in their customer_Group values.
Also use a user defined format to put customers in the age group of 15-30 as Group1 and 31- 45
as Group2.

Code of the program:

proc print data=oriona2.customer_dim;

run;

data work.youngadult;

set oriona2.customer_dim;
where Customer_Gender='F' and 18<=Customer_Age<=36 and Customer_Group contains
'Gold';

run;

proc format

value $grp '15-30 years' = 'Group 1'

'31-45 years' = 'Group 2';

proc print data=work.youngadult;

format Customer_Age_Group $grp.;

run;

Output of the Program:

Assignment 2:

Using the data set orion.employees, create a new data set emp_list by subsetting records with
city being ‘San Diego’ and birth date being greater than 20DEC1970.
Add a new column, salary_new to the data set which computes the salary with 10% bonus.
Sort the new data set by descending salary within descending marital status column.
Apply appropriate formats to the hire date, birth date and salary_new column. Use ID statement
with employee id column and display only name, gender, hire date, birth date and salary_new
column.
Code of the program:

proc print data=oriona2.employees;

run;

data work.emp_list;

set oriona2.employees;

where city='San Diego' and Birth_Date > '20DEC1970'd;

Salary_new = Salary * 1.1;

run;

proc sort data=work.emp_list out=work.sort_emp_list;

by descending Marital_Status descending Salary;

run;

proc print data=work.sort_emp_list;

by descending Marital_Status;

format Salary dollar12.2

birth_date mmddyy10.

hire_date mmddyy10.;

id Employee_ID;

var name gender hire_date salary_new;

run;

Output of the Program:


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

You might also like