You are on page 1of 4

EXERCISE 1

MTH3405 – APPLICATIONS OF SELECTED STATISTICAL PACKAGE


SEM II 2019/2020

1. For first time users in SAS, gives the correct order of SAS statements.

2. According to the following INPUT statement, what are the character values/character variable
are used to get the following output?

DATA example;
INPUT __________________;
DATALINES;
ABCDEFGHIJK
LMNOP QRST UV WXYZ
ABCDEF HIJKL
MN OP QRST UVWXYZ
RUN;
TITLE 'Output For Example 1';
PROC PRINT;
RUN;

3. When you write INPUT statements, which rule below is not applicable?
a) All variable names must be 8 characters or fewer.
b) For the list input style, missing values should be left as blanks.
c) For the column input style, blanks are allowed as character values.
d) Numerical values can be declared as characters for a character variable.

4. Write a SAS program to determine data set B from data set A?

Data Set A Data Set B


x y z
4 2 3 2 4 2 3
6 7 8 9 2 6 7
2 4 3 1 8 9 2
4 3 1

5. The following data represent persons in a class and consist of their name, age, sex, weight, and
height.

Audrey,41,M,74,170
Ron,42,M,68,166
Carl,32,M,70,155
Antonio,39,M,72,167
Deborah,30,F,66,124
Jacqueline,33,F,66,115
Helen,26,F,64,121
David,30,M,71,158
James,53,M,72,175
Michael,32,M,69,143
Ruth,47,F,69,139
Joel,34,M,72,163
Donna,23,F,62,98
Roger,36,M,75,160
Yao,.,M,70,145
Elizabeth,31,F,67,135
Tim,29,M,71,176
Susan,28,F,65,131

a) Copy and Paste the above dataset and store in a plain text file. Then, use the SAS INFILE
statement to read the data. (Noted: Do not remove the commas on the dataset).

b) Sort data set alphabetically by name.

c) Correct the following SAS program and make it more readable:

d) From data (b), how to specify the first 10 observations if the third observations, be the first to
be printed.

6. Suppose we have another new data set in addition to the person in a class data set (in question 5)
discussed earlier that contains weight and height information for the same people a year later. We
are interested to combines the old data sets (in question 5(a)) in the new data set. Using the
Merge statement, complete the SAS code.

_________
_________
cards;
80 175 55 164 100 160 84 170 86 125
76 129 66 120 84 155 65 171 79 155
53 150 65 162 92 100 80 165 74 155
73 149 68 181 69 135
;
_________
_________
_________
_________
7. Write a SAS program to create the data set below.

8. Write a SAS code to examine whether a variable stored as "quantity" is above 20 where list the
observations for quantity values of 25, 14, 23, 30, and 10. If quantity is greater than 20, the code
will print "You sold a lot". Otherwise Not enough for today.

9. Suppose that the lecturer uses the following Grades data set to calculate a final percentage grade
for each student and to determine whether they “pass” or “fail” the course. Student will pass the
course if they mark is at least 70%. Otherwise, student will fail the course if they mark is less
than 70%. Write a SAS code to identify the condition and the action in each of the IF-THEN
statements.

Name Quiz 1 Quiz 2 Quiz 3 Exam 1 Final


(Full Mark) (20) (20) (20) (100) (100)
Zaitun 11 18 18 89 54
Nazran 16 6 19 87 85
Atiqah 20 18 18 91 94
Marcellus 13 14 14 63 55
Hui Xin 18 19 20 83 67
Firdaus 13 5 17 62 53

A portion of the result of the PROC PRINT is shown below:

10. From Question 9, the lecturer now wants to give grades to the students as follows:

i. If FinalPercent more than 90%, the grade is A.


ii. If FinalPercent between 80% to 90%, the grade is B.
iii. If FinalPercent between 70% to 80%, the grade is C.
iv. If FinalPercent between 60% to 70%, the grade is D.
v. If FinalPercent less than 60%, the grade is F.
Write a SAS code in the above new statements and the output must be show the Name,
FinalPercent and Grade.

You might also like