Premium

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



Question : A SAS program is submitted and the following SAS log is produced:
2 data gt100;
3 set ia.airplanes
4 if mpg gt 100 then output;
22 202
ERROR: File WORK.IF.DATA does not exist.
ERROR: File WORK.MPG.DATA does not exist.
ERROR: File WORK.GT.DATA does not exist.
ERROR: File WORK.THEN.DATA does not exist.
ERROR: File WORK.OUTPUT.DATA does not exist.
ERROR 22-322: Syntax error, expecting one of the following: a name,
a quoted string, (, ;, END, KEY, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
5 run;
The IA libref was previously assigned in this SAS session.
Which one of the following corrects the errors in the LOG?

  : 	A SAS program is submitted and the following SAS log is produced:
1. Delete the word THEN on the IF statement.
2. Add a semicolon at the end of the SET statement.
3. Place quotes around the value on the IF statement.
4. Add an END statement to conclude the IF statement



Correct Answer 2 :


Explanation: In SET statement semicolon is missing, so SAS is considering each word after SET as a separate data set which is creating an Error.

So placing the semicolon in SET statement will serve the purpose.
What SET Does
Each time the SET statement is executed, SAS reads one observation into the program data vector. SET reads all variables and all observations from the input data sets unless you tell
SAS to do otherwise. A SET statement can contain multiple data sets; a DATA step can contain multiple SET statements. See Combining and Modifying SAS Data Sets: Examples.


Uses
The SET statement is flexible and has a variety of uses in SAS programming. These uses are determined by the options and statements that you use with the SET statement:
reading observations and variables from existing SAS data sets for further processing in the DATA step
concatenating and interleaving data sets, and performing one-to-one reading of data sets
reading SAS data sets by using direct access methods.







Question : The contents of the raw data file CALENDAR are listed below:
--------10-------20-------30
The following SAS program is submitted:
data test;
infile 'calendar';
input @1 date mmddyy10.;
if date = '01012000'd then event = 'January 1st';
run;
Which one of the following is the value of the EVENT variable?


  : The contents of the raw data file CALENDAR are listed below:
1. 01012000
2. January 1st
3. (missing numeric value)
4. The value cannot be determined as the program fails to execute due to errors.


Correct Answer 4 :


Explanation:

Formatted input enables you to supply special instructions in the INPUT statement for reading data. For example, to read numeric data that contains special symbols, you need to
supply SAS with special instructions so that it can read the data correctly. These instructions, called informats

data total_sales;
input Date mmddyy10. +2 Amount comma5.;
In this example, the MMDDYY10. informat for the variable Date tells SAS to interpret the raw data as a month, day, and year, ignoring the slashes. The COMMA5. informat for the
variable Amount tells SAS to interpret the raw data as a number, ignoring the comma. The +2 is a pointer control that tells SAS where to look for the next item.

However, SAS is also capable of reading two-digit year values (for example, 09/05/99). In this example, use the MMDDYY8. informat for the variable Date.
Answer D is because date constant is invalid. [Evern after providing correct date constant -date='01JAN2000'd desired output not produced and it produces Note: SAS went to a new line
when INPUT statement reached past the end of a line.]
The error that shown even on your correction is probably because the informat given is wrong. The informat should be 'mmddyy8.'. Once you do that, the event shows up as January 1st

If we provide correct date contant date='01jan2000'd, will get the result.
please try the below program.

data test;
infile datalines;
input @1 date mmddyy10.;
if date = '01jan2000'd then event = 'January 1st';
datalines;
;




Question : The following SAS program is submitted:

data work.january;
set work.allmonths (keep = product month num_sold cost);
if month = 'Jan' then output work.january;
sales = cost * num_sold;
keep = product sales;
run;
Which variables does the WORK.JANUARY data set contain?

  : The following SAS program is submitted:
1. PRODUCT and SALES only
2. PRODUCT, MONTH, NUM_SOLD and COST only
3. PRODUCT, SALES, MONTH, NUM_SOLD and COST only
4. An incomplete output data set is created due to syntax errors


Correct Answer : 4


Explanation: As there is syntax error.
"keep = product sales" which is the incorrect way to use KEEP option

It has syntax error is it due to
1) if month = 'Jan' then output work.january; or
2) keep = product sales;

For sure if it is with data line ( drop = variables) and no need = in the body separately.




Related 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.



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.


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)



Question : The contents of the raw data file AMOUNT are listed below:

--------10-------20-------30
$1,234
The following SAS program is submitted:
data test;
infile 'amount';
input @1 salary 6.;
if _error_ then description = 'Problems';
else description = 'No Problems';
run;
Which one of the following is the value of the DESCRIPTION variable?



  : The contents of the raw data file AMOUNT are listed below:
1. Problems
2. No Problems
3. ' ' (missing character value)
4. The value can not be determined as the program fails to execute due to errors



Question : The contents of the raw data file NAMENUM are listed below:

--------10-------20-------30
Joe xx
The following SAS program is submitted:
data test;
infile 'namenum';
input name $ number;
run;
Which one of the following is the value of the NUMBER variable?
  : The contents of the raw data file NAMENUM are listed below:
1. xx
2. Joe
3. . (missing numeric value)
4. The value can not be determined as the program fails to execute due to errors.



Question : Which one of the following statements is true regarding the SAS automatic _ERROR_ variable?

  : Which one of the following statements is true regarding the SAS automatic _ERROR_ variable?
1. The _ERROR_ variable contains the values 'ON' or 'OFF'.
2. The _ERROR_ variable contains the values 'TRUE' or 'FALSE'.
3. The _ERROR_ variable is automatically stored in the resulting SAS data set.
4. The _ERROR_ variable can be used in expressions or calculations in the DATA step.