Premium

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



Question :
Which one of the following is true of the RETAIN statement in a SAS DATA step program?
  :
1. It can be used to assign an initial value to _N_ .
2. It is only valid in conjunction with a SUM function.
3. Access Mostly Uused Products by 50000+ Subscribers
4. It adds the value of an expression to an accumulator variable and ignores missing values.

Correct Answer : Get Lastest Questions and Answer :

Explanation: It adds the value of an expression to an accumulator variable and ignores missing values.
The RETAIN statement
- is a compile-time only statement that creates variables if they do not already exist
- initializes the retained variable to missing before the first execution of the DATA step if you do not supply an initial value
- has no effect on variables that are read with SET, MERGE, or UPDATE statements.
First part "It adds the value of an expression to an accumulator variable."

"RETAIN variable
specifies the name of the accumulator variable, which contains a numeric value.
Tips:The variable is automatically set to 0 before SAS reads the first observation. The variable's value is retained from one iteration to the next, as if it had appeared in a RETAIN
statement. To initialize a sum variable to a value other than 0, include it in a RETAIN statement with an initial value.

RETAIN expression
is any SAS expression.
Tips:The expression is evaluated and the result added to the accumulator variable.
SAS treats an expression that produces a missing value as zero. " - Sas help and documentation







Question :
A raw data file is listed below:
--------10-------20-------30
1901 2
1905 1
1910 6
1925 .
1941 1
The following SAS program is submitted and references the raw data file above:
data coins;
infile 'file-specification';
input year quantity;

run;
Which one of the following completes the program and produces a non-missing value for the variable TOTQUANTITY in the last
observation of the output data set?

  :
1. totquantity + quantity;
2. totquantity = sum(totquantity + quantity);
3. Access Mostly Uused Products by 50000+ Subscribers
sum totquantity;
4. retain totquantity 0;
totquantity = totquantity + quantity;


Correct Answer : Get Lastest Questions and Answer :

Explanation: data aa;
x=.;
y=3;
z= x+y;
run;

z is missing.
Missing Values: When Missing Values are Generated by SAS

Expression cannot ignore missing value, but the SUM function and statement can.

A is the correct one, when we put the statement
totquantity + quantity , it initializes to zero in the first iteration and adds the quantity and gets the fist totquantity.
and so forth.

retain will not work in this data set. if you put the retain statement it will stop once reads the missing value the totquantity will be missing value ( . )






Question :
A raw data file is listed below:
--------10-------20-------30
squash 1.10
apples 2.25
juice 1.69
The following SAS program is submitted using the raw data file above:
data groceries;
infile 'file-specification';
input item $ cost;

run;
Which one of the following completes the program and produces a grand total for all COST values?


  :
1. grandtot = sum cost;
2. grandtot = sum(grandtot,cost);
3. Access Mostly Uused Products by 50000+ Subscribers
grandtot = sum(grandtot,cost);
4. grandtot = sum(grandtot,cost);
output grandtot;


Correct Answer : Get Lastest Questions and Answer :

Explanation: : sum is a function which means it will need brackets () so A is not the correct answer.
1 has incorrect syntax and will not compile. The idea of "sum cost" has some merit in the context of a proc print situation, but used in an assignment statement like this, it's just garbage.

There no such variable as grandtot, so program will give syntax error, so option B and D is not the correct answer.

2 will actually perform sum(.,cost) for each iteration... assigns this result (=cost) to grandtot, so the result is that grandtot equals the newly read value of cost each time...
because for each iteration grandtot is reset to missing, in the absence of a 'retain' SAS has no memory of the previous value. It compiles alright, but it doesn't produce the goods.

3 output grandtot; does NOT mean output the value of grandtot to the groceries dataset. It means send the output to a particular dataset called "grandtot". Since this dataset doesn't
in fact exist, as it wasn't declared in the data statement at the top, this is a compile time error.


4 is the correct option because retain statement is creating a new variable and initializing it with zero. Sum function will add cost to grandtot for each observation and as grandtot
is retained it will carry forward the added value.




Related Questions


Question : In your SAS program, you have defined following ODS statement. Which type of output will be created assuming all the settings are default
using below ODS statements?
Ods html file=/home/HE.html
Ods pdf file=/home/HE.pdf

 : In your SAS program, you have defined following ODS statement. Which type of output will be created assuming all the settings are default
1. HTML and PDF
2. Only HTML
3. Access Mostly Uused Products by 50000+ Subscribers
4. No output will be created because ODS is closed by default.



Question : You are writing a SAS program to generate the PDF output in a Window based environment. You have been asked to first close the html ods
using following statement
Ods html close;
Why?

 : You are writing a SAS program to generate the PDF output in a Window based environment. You have been asked to first close the html ods
1. It is good programming practice

2. It will format your code in HTML format

3. Access Mostly Uused Products by 50000+ Subscribers

4. Previously running SAS program can be stopped before running current program



Question : You have written following SAS program
ods html body='/folders/myfolders/hadoopexam/hesample101.html';
proc print data=course2017 ;
var COURSE_ID COURSE_NAME LOCATION FEE DATE DURATION ;
run;
proc print data=course2017 (Obs=5);
var COURSE_ID COURSE_NAME LOCATION FEE DATE DURATION ;
run;
ods html close;
ods html path="%qsysfunc(pathname(work))";

What would be the result, expected once this program will be executed?

 : You have written following SAS program
1. It will generate an HTML file with single report having 5 observations.

2. It will generate an HTML file with single report having all the observations from course2017 dataset.

3. Access Mostly Uused Products by 50000+ Subscribers

4. It will fail to generate report.



Question : You have written below statements for generating HTML output
ods html body='/folders/myfolders/hadoopexam/hesample102.html'
contents='/folders/myfolders/hadoopexam/contents.html'
frame='/folders/myfolders/hadoopexam/frame102.html';
Once successfully executed, than what is the expected in the contents.html file

 : You have written below statements for generating HTML output
1. It will have all the contents from the respective PROC step

2. It will have three separate reports generated.

3. Access Mostly Uused Products by 50000+ Subscribers

4. It will have links which points to the contents in the frame102.html file



Question : You have written below statements for generating HTML output
ods html body='/folders/myfolders/hadoopexam/hesample102.html'
contents='/folders/myfolders/hadoopexam/contents.html'
frame='/folders/myfolders/hadoopexam/frame102.html';
What contents.html file can have?

 : You have written below statements for generating HTML output
1. Heading for all the outputs generated from the PROC steps.

2. Heading for all the outputs generated from the DATA steps.

3. Access Mostly Uused Products by 50000+ Subscribers

4. Each HTML files till now have created using SAS program



Question : You have written below statements for generating HTML output
ods html body='/folders/myfolders/hadoopexam/hesample102.html'
contents='/folders/myfolders/hadoopexam/contents.html'
frame='/folders/myfolders/hadoopexam/frame102.html';

What would be there in frame102.html file?

 : You have written below statements for generating HTML output
1. It will have contents from contents.html file

2. It will have contents from hesample102.html file

3. Access Mostly Uused Products by 50000+ Subscribers

4. It does not have anything it, it is just a frame around the output.