Premium

Base SAS Certified Associate: Programming Fundamentals Using SAS Questions and Answers (Dumps and Practice Questions)



Question :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?

 :The following SAS program is submitted:
1. 6
2. 7
3. 8
4. . (missing numeric)

Correct Answer : 2
Because of prod + 1 statement, SAS compiler will assume a retain prod 0; statement.
First loop => prod = 1 => (1 gt 6) => false, loop continues

Second loop => prod = 2 => (2 gt 6) => false, loop continues
.....
last loop => prod = 7 => (7 gt 6) => true, do until loop exits and pdv writes prod value of 7 to output dataset.

Syntax
DO UNTIL (expression);
...more SAS statements...
END;

Arguments
(expression)
is any SAS expression, enclosed in parentheses. You must specify at least one expression.
Details
The expression is evaluated at the bottom of the loop after the statements in the DO loop have been executed. If the expression is true, the DO loop does not iterate again.
Note: The DO loop always iterates at least once.
There are three other forms of the DO statement:
The DO statement, the simplest form of DO-group processing, designates a group of statements to be executed as a unit, usually as a part of IF-THEN/ELSE statements.
The iterative DO statement executes statements between DO and END statements repetitively based on the value of an index variable.
The DO WHILE statement executes statements in a DO loop repetitively while a condition is true, checking the condition before each iteration of the DO loop. The DO UNTIL statement
evaluates the condition at the bottom of the loop; the DO WHILE statement evaluates the condition at the top of the loop.
Note: The statements in a DO UNTIL loop always execute at least one time, whereas the statements in a DO WHILE loop do not iterate even once if the condition is false.




Question :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?
 :The SAS data sets WORK.EMPLOYEE and WORK.SALARY are shown below:
1. merge work.employee
work.salary (fname = name);
2. merge work.employee
work.salary (name = fname);
3. merge work.employee
work.salary (rename = (fname = name));
4. merge work.employee
work.salary (rename = (name = fname));

Correct Answer : 4 Because the two data sets are merged by fname variable. You need to rename the name variable of the salary data set to fname. Correct way to rename is
(rename = (name = fname))
(rename = (original_var_name= new_var_name))
The original var in this case is name and needs to be renamed fname.
So 4 should be the correct answer.
You merge data sets using the MERGE statement in a DATA step. The form of the MERGE statement that is used in this section is the following:
MERGE SAS-data-set-list;
BY variable-list;
SAS-data-set-list is the names of two or more SAS data sets to merge. The list may contain any number of data sets.
variable-list is one or more variables by which to merge the data sets. If you use a BY statement, then the data sets must be sorted by the same BY variables before you can merge them.
Syntax
RENAME=(old-name-1=new-name-1 (...old-name-n=new-name-n))
Syntax Description :
old-name : the variable you want to rename.
new-name : the new name of the variable. It must be a valid SAS name.
If you use the RENAME= data set option when you create a data set, the new variable name is included in the output data set. If you use RENAME= on an input data set, the new name is
used in DATA step programming statements. If you use RENAME= on an input data set that is used in a SAS procedure, SAS changes the name of the variable in that procedure. If you use
RENAME= with WHERE processing such as a WHERE statement or a WHERE= data set option, the new name is applied before the data is processed. You must use the new name in the WHERE
expression. If you use RENAME= in the same DATA step with either the DROP= or the KEEP= data set option, the DROP= and the KEEP= data set options are applied before RENAME=. You must
use the old name in the DROP= and KEEP= data set options. You cannot drop and rename the same variable in the same statement.
Note: The RENAME= data set option has an effect only on data sets that are opened in output mode




Question :
The SAS data set PETS is sorted by the variables TYPE and BREED.
The following SAS program is submitted:
proc print data = pets;
var type breed;
sum number;
run;
What is the result?

 :
1. The SUM statement produces only a grand total of NUMBER.
2. The SUM statement produces only subtotals of NUMBER for each value of TYPE.
3. The SUM statement produces both a grand total of NUMBER and subtotals of NUMBER for each value of TYPE.
4. Nothing is produced by the SUM statement; the program fails to execute.


Correct Answer : 1



Related Questions


Question : Given the SAS data set AGES:
AGES
AGE
---------
The variable AGE contains character values. The following SAS program is submitted:

data subset;
set ages;
where age> 12;
run;

How many observations are written out to the data set SUBSET?

 : Given the SAS data set AGES:
1. 0
2. 1
3. Access Mostly Uused Products by 50000+ Subscribers
4. 3


Question :
---+----10---+----20---+
son Frank 01/31/89
daughter June 12-25-87
brother Samuel 01/17/51

The following program is submitted using this file as input:

data work.family;
infile 'file-specification';
(insert INPUT statement here)
run;

Which INPUT statement correctly reads the values for the variable Birthdate as SAS date values?
 :
1. input relation $ first_name $ birthdate date9.;
2. input relation $ first_name $ birthdate mmddyy8.;
3. Access Mostly Uused Products by 50000+ Subscribers
4. input relation $ first_name $ birthdate : mmddyy8.;


Question :
1---+----10---+----20---+
Jose,47,210
Sue,,108
The following program is submitted using the raw data file above as input:

data employeestats;
(insert INFILE statement here)
input name $ age weight;
run;
The following output is desired:

name age weightJose 47 210Sue . 108

Which of the following INFILE statement completes the program and accesses the data correctly?


  :
1. infile 'file-specification' pad;
2. infile 'file-specification' dsd;
3. Access Mostly Uused Products by 50000+ Subscribers
4. infile 'file-specification' missover;


Question : The following program is submitted:

data numrecords;
infile cards dlm=',';
input agent1 $ agent2 $ agent3 $;
cards;
jones,,brownjones,spencer,brown;
run;

What is the value for the variable named Agent2 in the second observation?


 : The following program is submitted:
1. brown
2. spencer
3. Access Mostly Uused Products by 50000+ Subscribers
4. There is no value because only one observation is created


Question :
1---+----10---+----20---+----30---+----40---+----50
TWOSTORY 1040 2 1SANDERS ROAD $55,850
CONDO 2150 4 2.5JEANS AVENUE $127,150
The following program is submitted using this file as input:

data work.houses;
infile 'file-specification';
(insert INPUT statement here)
run;
Which one of the option from left image, INPUT statements reads the raw data file correctly?

  :
1.
2.
3. Access Mostly Uused Products by 50000+ Subscribers
4.


Question : The SAS data set Sasdata.Salesdata has ten observations. Which one of the following explains why a report fails to generate?

  :  The SAS data set Sasdata.Salesdata has ten observations. Which one of the following explains why a report fails to generate?
1. The DATA step fails execution.
2. The SAS data set Sales does not exist.
3. Access Mostly Uused Products by 50000+ Subscribers
4. The PRINT procedure contains a syntax error.