Practical No. 9: Aim: To Explicitly Control The Output of Multiple Observations To A SAS Data Set and Create

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Practical No.

9
Aim: To explicitly control the output of multiple observations to a SAS data set and create
multiple SAS data sets using conditional processing.

Prerequisite:

1. Understanding of fundamental programming constructs of Base SAS

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

1. Use explicit OUTPUT statement to write PDV contents to a data set.


2. Use conditional processing to control the data set to which an observation is written.
3. Use OBS= and FIRSTOBS= option to control the observations being processed.

(TO BE COMPLETED BY STUDENTS)

Roll No. Name:


Class: Batch:
Date of Practical: Date of Submission:
Grade:

Assignment 1:

For the following program.

proc print data=orion.prices;


run;

 Write a data step to create a new data set work.price_increase that forecasts unit prices for
the next 3 years. Use explicit OUTPUT statements to forecast Unit_price for the next 3 years
using Factor as the annual rate of increase.

 Print the new data set to include only product_id, unit_price and year.

Code of the program:

Output of the Program:


Assignment 2:

Read the data set orion.orders.

 Create 3 data sets named work.fast, work.slow and work.veryslow.


 Write a WHERE statement to read only the observations with order_type =2 or 3.
 Create a variable named Shipdays that is the number of days between when the order is
placed and when is it delivered.
 Handle the outputs as follows.
o Output to work.fast when value of Shipdays is less than 3.
o Output to work.slow when value of Shipdays is 5 to 7.
o Output to work.veryslow when value of Shipdays is greater than 7.
o Do not output an observation when value of Shipdays is 3 or 4
 Drop the variable employee_id
 Print the result of all 3 new data sets created with appropriate title.

Code of the program:

Output of the Program:

Assignment 3:

 Read the data set product_dim.


 Create 2 data sets named work.children and work.clothes.
 Output to these data sets depending on whether the value of product_line is ‘Children’ or
‘Clothes & Shoes’.
 Work.children should contain only product_id, product_category and supplier_country.
 Work.clothes should contain only product_id and supplier_id.
 Print only the first 6 observations from work.children.
 Print the selected observation – 2 and 3 from work.clothes.

Code of the program:

Output of the Program:

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

You might also like