NEW
Font size
WorksheetsSAS Programming 1 Revision 2
Total questions: 10
Worksheet time: 5mins
Given the following SAS data sets ONE and TWO:
DATA three;
Merge one (in = in1) two (in = in2);
By num;
Run;
DATA three;
Merge one (in = in1) two (in = in2);
If in1 = 1 and in2 = 1;
Run;
DATA three;
Merge one (in = in1) two (in = in2);
If in1 = 1;
Run;
DATA three;
Merge one (in = in1) two (in = in2);
By num;
If in1 and in2;
Run;
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
I and IV only
I, II and III
II, III and IV
All of the given answers
What belongs within the braces of this ARRAY statement?
ARRAY scores{?} test1-test3;
test*
test
1 - 3
3
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?
PROC sort data=work.SortObs out=Sales;
Run;
PROC sort data=work.Sales out=work.SortObs;
By ProductID;
Run;
PROC sort data=work.SortObs;
By ProductID;
Run;
PROC sort data=work.SortObs out=work.Sales;
By ProductID;
Run;
Which DO statement would NOT process all the elements in the factors array shown below?
ARRAY factors(*) age weight height heartrate;
DO a = 1 to dim(factors);
DO a = 1 to dim(*);
DO a = 1,2,3,4;
DO a = 1 to 4;
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?
SalesTarget = input (Target, comma4.);
SalesTarget = input (Target, comma5.);
SalesTarget = put (Target, comma4.);
SalesTarget = put (Target, comma5.);
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?
IF EyeColour = ‘black’ OR ‘brown’ THEN Flag = 0;
IF EyeColour = ‘black’ OR EyeColour = ‘brown’ THEN Flag = 0;
IF EyeColour IN (‘black’, ‘brown’) THEN Flag = 0;
All of the given answers will work
When SAS encounters a syntax error, what is displayed in the log?
An error messages
The possible location of the error
An explanation of the error
All of the given answers
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;
No data set is created due to syntax errors in the program
10
9
8
What is the main difference in the naming convention for SAS librefs versus SAS variables?
Librefs can contain special characters such as %, # and $
Variable names are case sensitive
Librefs can only be up to 8 characters long
Variable names can contain underscore
