Professional Documents
Culture Documents
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.
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).
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.
10. From Question 9, the lecturer now wants to give grades to the students as follows: