The following SAS program is submitted:
data one;
addressl = 214 London Way;
run;
data one;
set one;
address = tranwrd(address1, Way, Drive); run;
What are the length and value of the variable ADDRESS?
Correct Answer: D
The length of the new variable created by the tranwrd function is automatically set to 200 bytes if the length is not previously defined. Therefore, the length is 200. Additionally, the value of the variable 'address' after the substitution in the tranwrd function will be '214 London Drive'.
The following SAS program is submitted:
data work.sets;
do until (prod gt 6);
prod + 1;
end;
run;
What is the value of the variable PROD in the output data set?
Correct Answer: B
In the provided SAS program, a DO UNTIL loop is used, which will continue executing until the condition (prod > 6) is met. Initially, the variable PROD is implicitly set to 0. The loop increments PROD by 1 in each iteration. The loop will execute as long as PROD is less than or equal to 6. The looping stops when PROD becomes 7 after it is incremented from 6. Hence, the final value of the variable PROD in the output data set is 7.
The SAS data sets WORK.EMPLOYEE and WORK.SALARY are shown below:
WORK.EMPLOYEE WORK.SALARY -
fname age name salary
Bruce 30 Bruce 25000 -
Dan 40 Bruce 35000 -
Dan 25000 -
The following SAS program is submitted:
data work.empdata;
by fname;
totsal + salary;
run;
Which one of the following statements completes the merge of the two data sets by the FNAME variable?
Correct Answer: C
To complete the merge of the two datasets by the FNAME variable, you need to account for the different names of the key variable in each dataset. In the WORK.EMPLOYEE dataset, the key variable is FNAME, while in the WORK.SALARY dataset, it is NAME. Thus, you should use the RENAME= data set option to standardize the key variable name before performing the merge. The correct syntax for this is 'merge work.employee work.salary (rename = (name = fname));'. This way, the NAME variable in WORK.SALARY is renamed to FNAME, allowing the datasets to be merged by the FNAME variable.
The following SAS program is submitted:
proc sort data = work.employee;
by descending fname;
proc sort data = work.salary;
by descending fname;
data work.empdata;
merge work.employee
work.salary;
by fname;
run;
Why does the program rail to execute?
Correct Answer: C
The program fails to execute because the RUN statement was omitted after each of the SORT procedures. In SAS, each PROC or DATA step must be concluded with a RUN statement to execute properly. Without the RUN statement, SAS does not know to execute the PROC SORT steps before attempting to merge the data sets in the DATA step.
The following SAS program is submittad:
data work.sales;
do year = 1 to 5;
do month=1 to 12;
x+1;
output
end;
end;
run;
How many observations are written the WORK SALES data set?
Correct Answer: D
The SAS program uses two nested DO loops where the outer loop iterates from year 1 to 5 and the inner loop iterates from month 1 to 12. For each iteration of the inner loop, the value of x is incremented and an OUTPUT statement writes an observation to the data set. The outer loop runs 5 times and for each run of the outer loop, the inner loop runs 12 times, resulting in a total of 5 * 12 = 60 observations being written to the WORK.SALES data set.