wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

SAS Programming 1 Revision 2

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Given the following SAS data sets ONE and TWO:

a)

DATA three;

Merge one (in = in1) two (in = in2);

By num;

Run;

b)

DATA three;

Merge one (in = in1) two (in = in2);

If in1 = 1 and in2 = 1;

Run;

c)

DATA three;

Merge one (in = in1) two (in = in2);

If in1 = 1;

Run;

d)

DATA three;

Merge one (in = in1) two (in = in2);

By num;

If in1 and in2;

Run;

2.

Which statement is TRUE regarding an ARRAY statement?

 

I.               It is an executable statement

II.             It can be used to create variables

III.            It must contain either all numeric or all character elements

IV.           It must be used to define an array before the array name can be referenced

a)

I and IV only

b)

I, II and III

c)

II, III and IV

d)

All of the given answers

3.

What belongs within the braces of this ARRAY statement?

 

ARRAY scores{?} test1-test3;

a)

test*

b)

test

c)

1 - 3

d)

3

4.

If you want to sort your data and create a temporary data set named SortObs to store the sorted data, which of the following steps should you submit?

a)

PROC sort data=work.SortObs out=Sales;

Run;

b)

PROC sort data=work.Sales out=work.SortObs;

By ProductID;

Run;

c)

PROC sort data=work.SortObs;

By ProductID;

Run;

d)

PROC sort data=work.SortObs out=work.Sales;

By ProductID;

Run;

5.

Which DO statement would NOT process all the elements in the factors array shown below?

 

ARRAY factors(*) age weight height heartrate;

a)

DO a = 1 to dim(factors);

b)

DO a = 1 to dim(*);

c)

DO a = 1,2,3,4;

d)

DO a = 1 to 4;

6.

A typical value for the character variable Target is 5,750. Which statement correctly converts the values of Target to numeric values when creating the variable SalesTarget?

a)

SalesTarget = input (Target, comma4.);

b)

SalesTarget = input (Target, comma5.);

c)

SalesTarget = put (Target, comma4.);

d)

SalesTarget = put (Target, comma5.);

7.

Which of the following IF-THEN statements will NOT assign a value of 0 to the variable named Flag for students with eye colour of black or brown?

a)

IF EyeColour = ‘black’ OR ‘brown’ THEN Flag = 0;

b)

IF EyeColour = ‘black’ OR EyeColour = ‘brown’ THEN Flag = 0;

c)

IF EyeColour IN (‘black’, ‘brown’) THEN Flag = 0;

d)

All of the given answers will work

8.

When SAS encounters a syntax error, what is displayed in the log?

a)

An error messages

b)

The possible location of the error

c)

An explanation of the error

d)

All of the given answers

9.

What is the length of the variable Q in the resulting SAS data set called DRINK?

 

DATA drink;

SET fresh (KEEP = Y);

IF Y < 2 THEN Q = 'Purified';

ELSE Q = 'Distilled';

LENGTH Q $ 10;

RUN;

a)

No data set is created due to syntax errors in the program

b)

10

c)

9

d)

8

10.

What is the main difference in the naming convention for SAS librefs versus SAS variables?

a)

Librefs can contain special characters such as %, # and $

b)

Variable names are case sensitive

c)

Librefs can only be up to 8 characters long

d)

Variable names can contain underscore