Perform conditional processing that makes decisions

Assignment Help Other Subject
Reference no: EM133147843 , Length: word count:800

ITECH3101 Business Analytics and Decision Support - Federation University

Exercise - SAS programming -2 Conditional and looping processing

Project 1: Conditional processing

All programming languages allow us to perform conditional processing that makes decisions based on data values or other conditions. We can perform conditional processing logic with IF-THEN statement.

1. IF-THEN statement

IF-THEN statement takes form of:

IF condition THEN action;

The condition is an expression comparing one thing to another, and the action is what SAS should do when the expression is true. for example

IF Model = 'Berlinetta' THEN Make = 'Ferrari';

This statement tells SAS to set the variable Make equal to Ferrari whenever the variable Model equals Berlinetta. The basic comparison operators are as follow:

Symbolic

Mnemonic

Meaning

=

EQ

equals

^= or ~=

NE

not equal

GT

greater than

LT

less than

>=

GE

greater than or equal

<=

LE

less than or equal

The IN operator compares the value of a variable to a list of values. IF Model IN ('Model T, 'Model A') THEN Make = 'Ford';

This statement tells SAS to set the variable Make equal to Ford whenever the value of variable Model is Model T or Model A.

2. IF-THEN statement plus keywords DO and END

A single IF-THEN statement can only have one action. If we add the keywords DO and END, then we can execute more than one action.

IF condition THEN DO; IF Model = 'DMC-12' THEN DO;
action; Make = 'Delorean';
action; BodyStyle = 'coupe';
END; END;

The DO statement causes all SAS statements coming after it to be treated as a unit until a matching END statement appears.

AND and OR comparison operators

Symbolic

Mnemonic

Meaning

&

AND

All comparisons must be

true

|, or !

OR

Only one comparison must

be true

Examples

Download Dataset: Auction.dat from Week 8 in Moodle and save it under myfolders on your computer.

In above code, the first IF-THEN creates a new variable named Veteran and gives it a value of Yes for any car made before 1890. The second IF-THEN uses DO and END to fill in missing data for the model F-88.

After clicking Run tap, we get:

3. IF-THEN /ELSE statement

IF-THEN statement can be used to group observations. The simplest way to create a grouping variable is with a series of IF-THEN statements. By adding the keyword ELSE to IF statements, we can tell SAS that these statements are related.
IF-THEN/ELSE logic takes form of IF condition THEN action;
ELSE IF condition THEN action; ELSE IF condition THEN action;

Examples

Download Dataset: Home.dat from Week 8 in Moodle and save it under myfolders on your computer.

In above code, the first statement deals with observations that have missing data for the variable Cost. SAS considers missing values to be smaller than non-missing values, smaller than any printable character for character variables, and smaller than negative numbers for numeric variables.

So failing to account for missing values in a DATA step is the most common logic error in SAS programming.

The last ELSE statement contains just an action, with no IF or THEN. This kind of ELSE becomes a default which is automatically executed for all observations failing to satisfy any of the previous IF statements. We can only have one of these statements.

Project 2: Looping processing

Many programs use looping processing that executes a series of statements a fixed number of times or sets a condition causing the loop to start or stop.

1. Do Loops

SAS iterative statements start with the keyword DO and are called as DO loops. The general form of a DO loop is

do variable = lower-limit to upper-limit by increment; SAS statements;
end;

Usually SAS writes an observation to a data set at the end of the DATA step, but we can override this default using the OUTPUT statement. If we want to write several observations for each pass through the DATA step, we can put an OUTPUT statement in a DO loop.

Example 1

In above code, DO loop has six iterations. An observation is created each time through the loop because OUTPUT statement is inside the DO loop. Without the OUTPUT statement, SAS would have written only one observation at the end of DATA step.

After clicking Run tap, we get:

Example 2

In above code, data in the datalines expresses heart rates for subjects given one of three drugs: Placebo, Drug A and Drug B. Each line of data contains three heart rates, one for each of three drug group.

The trailing @ sign("hold the line") allows the program to read all three values from one line of data. The trailing @ sign on the input statement prevents SAS from going to a new line each time the loop iterates and INPUT statement is executed. noobs in proc print statement would remove the Obs from the output of proc print.

After clicking Run tap, we get:

2. DO WHILE loop
The syntax of DO WHILE loop is do while (expression);
SAS statements;
end;

where expression is a SAS logic expression. Example

After clicking Run tap, we get:

3. DO UNTIL loop

A DO UNTIL loop will continue to loop until the UNTIL condition is true. The UNTIL condition is evaluated at the bottom of the loop. Therefore, DO UNTIL loops will always execute at least one time.

Example

After clicking Run tap, we get:

Project 3. Answering questions (Please do this at your home by using your own computer)

1. Name and briefly describe four of the most popular commercial software tools used for text mining.
2. In application Case 7.3: Mining for Lies, how can text/data mining be used to detect deception in text?

3. You have data from three groups of subjects (Groups A, B and C). The actual data looks like this:

Group Score
A 10
B 11
C 12
A 20
B 21
C 22

However, the data was entered without the group, like this:

Data for Group Study 10
11
12
20
21
22

Write a program to read the six numbers shown here(use DATALINES) to create a table with the variables Group and Score.

Project 4. Creating a Professional Report

Summarize the above experiments procedure, results, answering questions and screenshots (project 1, 2, 3) into one report. Your report is the assignment that is required to be submitted for evaluation on week 11. Create a report by following below steps.

You can add a chapter called Chapter 8 in your previous report.

1. Open your last week's report and find the end of last week's report.

2. Copy this week's related experimental results, your findings and Screenshots, and paste them at the end of last week's report.

3. Delete original Table of Content you created.

4. Select all content , align all text to both left and right margin

5. Use shortcut key approach, generate Chapter 8: SAS programming -2 Conditional and looping processing

6. Then use shortcut key approach to generate proper sub-chapters for this week's lab work.

7. Insert Table of Contents to your report.

Attachment:- Business Analytics and Decision Support.rar

Reference no: EM133147843

Questions Cloud

Calculate the cash proceeds from the issuance of these bonds : On August 1, 2020, Tra Vinh Corporation issued $128.30 million in 5% bonds, Calculate the cash proceeds from the issuance of these bonds
Discuss how a business can reduce environmental pollution : Discuss how a business can reduce environmental pollution and make a profit. You can choose any business sector.
What was the list price of the printer : Marissa paid $250.48 for a printer that she purchased after receiving trade discounts of 13%, 8%, and 1%. What was the list price of the printer
Who will be the various stakeholders of business : Imagine you are thinking about opening a restaurant in your community.
Perform conditional processing that makes decisions : SAS programming - Conditional and looping processing - perform conditional processing that makes decisions based on data values or other conditions
Weaknesses of marriot city centre toronto : Minimum 10 weaknesses of Marriot City Centre Toronto in respect of the housekeeping department with in text citation and references.. Specifically Marriot City
Assignment on conflict management : The following scenario highlights the importance of conflict management in organizations. These conflict management competencies include explaining conflict man
Adopt a team orientation culture : To what extent do you think the organizational behaviour dependent variable would be impacted if many Jamaican organizations were to adopt a team orientation cu
Purpose and components of the theory or model : For this assignment, research two theories or models that might be useful in a quantitative study

Reviews

Write a Review

Other Subject Questions & Answers

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd