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.totalsales;
set work.monthlysales(keep = year product sales);
retain monthsales {12} ;
array monthsales {12} ;
do i = 1 to 12;
monthsales{i} = sales;
end;
cnt + 1;
monthsales{cnt} = sales;
run;
The data set named WORK.MONTHLYSALES has one observation per month for each of five years for a total of 60 observations. Which one of the following is the result of the above
program?
  : The following SAS program is submitted:
1. The program fails execution due to data errors.
2. The program fails execution due to syntax errors.
3. The program runs with warnings and creates the WORK.TOTALSALES data set with 60 observations.
4. The program runs without errors or warnings and creates the WORK.TOTALSALES data set with 60 observations.


Correct Answer : 2

Explanation: Answer is B because retain statement for arrays should look something like retain monthsales1-monthsales12;
Even if we change retain statement to proper one, program will error out. Because array index will be out of bound after reading 13th observation. Below is my code and log file.

data monthly (keep = sales);
do i = 1 to 60;
sales = i*10;
output;
end;
run;
data work.totalsales;
set work.monthly(keep = sales);
retain msales1-msales12 ;
array msales {12} ;
do i = 1 to 12;
msales{i} = sales;
end;
cnt + 1;
msales{cnt} = sales;
run;
ERROR: Array subscript out of range at line 227 column 1.
SALES=130 MSALES1=130 MSALES2=130 MSALES3=130 MSALES4=130 MSALES5=130 MSALES6=130 MSALES7=130 MSALES8=130 MSALES9=130 MSALES10=130 MSALES11=130 MSALES12=130 I=13 CNT=13 _ERROR_=1
_N_=13 NOTE: The SAS System stopped processing this step because of errors. NOTE: There were 13 observations read from the data set WORK.MONTHLY.
WARNING: The data set WORK.TOTALSALES may be incomplete. When this step was stopped there were 12 observations and 15 variables.
WARNING: Data set WORK.TOTALSALES was not replaced because this step was stopped






Question : The following SAS program is submitted:
data work.totalsales (keep = monthsales{12} );
set work.monthlysales (keep = year product sales);
array monthsales {12} ;
do i=1 to 12;
monthsales{i} = sales;
end; run;
The data set named WORK.MONTHLYSALES has one observation per month for each of five years for a total of 60 observations.
Which one of the following is the result of the above program?
 :  The following SAS program is submitted:
1. The program fails execution due to data errors.
2. The program fails execution due to syntax errors.
3. The program executes with warnings and creates the WORK.TOTALSALES data set.
4. The program executes without errors or warnings and creates the WORK.TOTALSALES data set.

Correct Answer : 2

Explanation: : data monthly (keep = sales);
do i = 1 to 60; sales = i*10; output;
end; run;
data work.totalsales(keep = msales{12} ) ;
set work.monthly (keep = sales);
array msales {12} ;
do i=1 to 12; msales{i} = sales; end; run;
log file:
153 data work.totalsales(keep = msales{12} ) ;
23
ERROR 214-322: Variable name { is not valid.
ERROR 23-7: Invalid value for the KEEP option.
23
153! data work.totalsales(keep = msales{12} ) ;
ERROR 214-322: Variable name 12 is not valid.
153! data work.totalsales(keep = msales{12} ) ;
ERROR 214-322: Variable name } is not valid.
Program will run without errors if we change keep = statement as
data work.totalsales(keep = msales1-msales12 ) ;
set work.monthly (keep = sales);
array msales {12} ; do i=1 to 12; msales{i} = sales;
end;run;
we can't use array variables in the keep/drop options because array variables are temporary and available only at the time of execution. we have to mention the name of the variables
created by array if required in the keep option




Question : The following SAS program is submitted:
data test;
set sasuser.employees;
if 2 le years_service le 10 then
amount = 1000;
else if years_service gt 10 then
amount = 2000;
else
amount = 0;
amount_per_year = years_service / amount;
run;
Which one of the following values does the variable AMOUNT_PER_YEAR contain if an employee has been with the company for
one year?

  : The following SAS program is submitted:
1. 0
2. 1000
3. 2000
4. . (missing numeric value)


Correct Answer : 4


Explanation: The Answer will be 4 as amount will be 0 and the per_year should be calculated only if amount ne 0. Assuming the variable name are valid.
For variable names only, SAS remembers the combination of uppercase and lowercase letters that you use when you create the variable name. Internally, the case of letters does not
matter. "CAT," "cat," and "Cat" all represent the same variable. But for presentation purposes, SAS remembers the initial case of each letter and uses it to represent the variable
name when printing it.

The variable length is not a problem, it can be more than 8 chars. Variable name is not a problem,
1. Since division by zero, Mathematical operations could not be performed
2. The results of the operations have been set to missing values




Related Questions


Question : Which one of the following is true when SAS encounters a data error in a DATA step?

  : Which one of the following is true when SAS encounters a data error in a DATA step?
1. The DATA step stops executing at the point of the error, and no SAS data set is created.
2. A note is written to the SAS log explaining the error, and the DATA step continues to execute.
3. A note appears in the SAS log that the incorrect data record was saved to a separate SAS file for further examination.
4. The DATA step stops executing at the point of the error, and the resulting DATA set contains observations up to that point.


Question : You have been given below dataset, how many observation and variables it has ?

 : You have been given below dataset, how many observation and variables it has ?
1. 10 Observation and 10 Variables

2. 9 Observation and 9 variables

3. 10 Observation and 9 variables

4. 9 observation and 10 variables

5. There is one value missing, so we cannot tell.




Question : You have been given below SAS program
data hadoopexam.courses;
infile hadoopexam1;
input name $ price ;
run;
proc sort data=hadoopexam.courses;
by price;
run;
proc print data=hadoopexam.courses;
run;

You run this program, than how many steps will be processed in total?


 : You have been given below SAS program
1. 1

2. 2

3. 3

4. 10

5. How SAS executes the steps internally, cannot be identified.



Question : You have been given below SAS dataset, what is the type of the name variable
 : You have been given below SAS dataset, what is the type of the name variable
1. Numeric

2. Character

3. Floating Point Number

4. Variable



Question : In the given dataset, what is the datatype of date variable?


 : In the given dataset, what is the datatype of date variable?
1. Date

2. Character

3. Numeric

4. Floating Point



Question : You have set a system option like VALIDVARNAME=ANY. Which of the following is a valid variable name?

 : You have set a system option like VALIDVARNAME=ANY. Which of the following is a valid variable name?
1. 4HadoopExam

2. $Price

3. _HadoopExam_

4. Hadoop-Exam

5. All of the above are fine