0% found this document useful (0 votes)
112 views

SAS Lab Manual-I

The document outlines 10 lab assignments for an Advanced DBMS course using SAS, including creating datasets, subsetting data, exporting from and importing data to SAS, using conditional and iterative constructs, handling dates and subsetting, and performing data analytics and case studies to achieve various course outcomes related to data management and analysis skills.

Uploaded by

Ayushi Chauhan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views

SAS Lab Manual-I

The document outlines 10 lab assignments for an Advanced DBMS course using SAS, including creating datasets, subsetting data, exporting from and importing data to SAS, using conditional and iterative constructs, handling dates and subsetting, and performing data analytics and case studies to achieve various course outcomes related to data management and analysis skills.

Uploaded by

Ayushi Chauhan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

New Delhi Institute of Management

Advanced DBMS Using SAS


Lab Manual
INDEX
Lab Manual
S. No. Lab Manual Assignments Course Outcome

1. Creating Datasets Using Datalines CO3


2 Subsetting CO3
3 Exporting Data from SAS CO3
4 Reading Data into SAS from .TXT or .XLSX CO3
5 Conditional & Iterative Constructs CO3

6 Handling Date & Subsetting CO3


7 Data Analytics Using SAS Statistical Functions CO4

8 Advanced Analytics Using SAS CO4


9 Case Study – 1 CO3, CO4

10 Case Study – 2 CO3, CO4


9 Project CO3, CO4

Creating Datasets Using Datalines


1. Create a data set Number that contains the following 3 variables:

Var1 = 123
Var2 = 356
Var3 = 923

2. Create a data set Food that contains the following variables:

Restaurant: Burger King
NumEmploy: 5
Location: Toronto

3. Create a data set SCORE that contains the following variables:


4. Create a data set PROFILE that contains the following variables:

5. Create a data set PROFILE-1 that contains the following variables: (Hint: Length Statement)

Subsetting
1. From the last exercise, create a new data set called NEW_PROFILE from PROFILE using
the SET statement.
2. Create a new data set called ENROL based on the PROFILE data set. ENROL should
contains only the patients enrolled in the study (ENROL = YES)
3. Locate the HOLIDAY data set from SASHELP. Create a subset of the HOLIDAY data set that
contains only the holidays that fall in January. Name the new data set as JanHol and have it
created in the WORK library. How many observations are there in the subset?
Exporting Data from SAS
5 Steps to Export Data:
Step 1: Right-click the data set that you'd like to export.

Step 2: Click Export from the list.

Step 3: Select the shared folder where the data set should be exported to.

Step 4: Name the file to be exported (from Filename).

Step 5: Select the type of file to be exported (Excel, Text, CSV ...etc.)

1. Locate the CP951 data set from the SASHELP library. Save the CP951 data set into the
shared folder myfolders. 
2. Locate the ELECTRIC data set from the SASHelplibrary. Export ELECTRIC into an
Excel spreadsheet. Ensure the Excel spreadsheet contains the same rows and columns as
the SAS data set.
Reading Data into SAS from .TXT or .XLSX
1. Consider the following data stored in a TXT File
Store Data
Store Revenue Staff Salary Operation Profit Complaint Turnover
STORE101 128000 18 29200 15200 83600 5 2
STORE102 158000 17 19000 12000 127000 11 2
STORE103 138000 18 26300 10500 101200 7 1
STORE104 101000 17 19700 19700 61600 5 2
STORE105 123000 15 29500 10400 83100 7 1
STORE106 189000 13 24400 12600 152000 5 2
STORE107 135000 10 24800 11900 98300 5 2
STORE108 130000 14 19400 11000 99600 3 1
STORE109 191000 12 28300 10500 152200 8 2
STORE110 176000 10 23500 15900 136600 9 1

Your boss needs a SAS data set that contains only the stores with Revenue per Staff higher than
$10,000. Write a SAS code to extract this information.
2. Create a text file Temperature containing Temperature in Celcius on specific dates. Read it
into SAS and display the temperature in Fahrenheit.
3. Create a file in Excel Grades.xlsx which contains data on Student Grades. Use Import
statement to read data from this file into SAS dataset.
4. Create the following data in an Excel Sheet and import it in SAS.

EmpID Lastname Firstname JobCode Annual Salary

31 GOLDENBERG DESIREE PLT 50221.62

40 WILLIAMS ARLENE M. FLTAT 23666.12

71 PERRY ROBERT A. FLTAT 21957.71

82 MCGWIER-WATTS CHRISTINA PLT 96387.39

91 SCOTT HARVEY F. FLTAT 32278.4

106 THACKER DAVID S. FLTAT 24161.14

355 BELL THOMAS B. PLT 59803.16

366 GLENN MARTHA S. PLT 120202.38


Conditional & Iterative Constructs
1. Create an Excel File with fields as: EMPID, NAME & AGE. Import the file in SAS and display the data
with one additional field Age_Group calculated as per the below stated categories. (Note- Leave Age
field blank for at least 2 records to exercise the missing option.)

If missing (Age) then Age_Group= . ;

Else if Age le 20 then Age_Group= 1;

Else if Age le 40 then Age_Group= 2;

Else if Age le 60 then Age_Group= 3;

Else if Age le 80 then Age_Group= 4;

Else if Age gt 80 then Age_Group= 5;

2. Consider SAShelp data set Retail, write a program to create a new data set (Sales_Status) with the
help of following variables:

If sales greater than or equal to 300 set Bonus equal to ‘Yes’ and Level to ‘High’. Otherwise, if sales is
not missing, set Bonus to ‘NO’ and Level to ‘Low’. List the observations in this data set.

3. Create a conversion table for pounds and kilograms. The table should have one column showing
pounds from 0 to 100 in units of 10. The second column should show the kilogram equivalents. Note:
1KG =2.2 Lbs.

4. You have a variable called Money initialized at 100. Write a DO WHILE loop that compounds this
amount by 3 percent each year and computes the amount of money plus interest for each year. Stop
when the total amount exceeds 200.
Handling Date & Subsetting
1. Consider the Employee Excel Sheet created in Section “Reading Data into SAS from .TXT or .XLSX”,
Q.4. Add fields DOB and DOJ referring to Date of Birth and Date of Joining of Employees. Import this file
and calculate the ages and years of experience of all employees as two new fields in your SAS datasets.

2. From the dataset created in above question display the records of employees who have experience
greater than or equal to 10 years.

3. Consider SAS help data set CARS, create two temporary data sets. The first named CHEAP should
include all observations from Cars where the MSRP (manufacturer’s suggested retail price) is less than or
equal to $11,000. The other EXPENSIVE should include all observations from Cars where MSRP is greater
than or equal to $100,000. Include only the fields Male, Type, Origin and MSRP. List observations from
both data sets. The program should take care that if there are missing values for MSRP, then those
observations must not be written to CHEAP.

4. Using the CARS permanent SAS dataset, write SAS code to do the following:

a) Create a subset (SMALL) consisting of all vehicles whose engine size is less than 2.0 L. On the basis of
this dataset, find the average city and highway miles per gallon for these vehicles.

b) Create a subset (HYBRID) of all hybrid vehicles in the dataset. For these vehicles:

List the brand and Model Name.

Find the average city and highway miles per gallon.

c) Create a subset (AMDSUV) consisting of all vehicles that are both SUVs and have all-wheel drive. Sort
the data by highway miles per gallon. List the BRAND, MODEL and highway miles per gallon for this
sorted data.

You might also like