For other parts of the topics being tested go to the SAS Exam: Complete Guide.

To look at some SAS Base Exam Questions to practice your SAS skills, go to the SAS Base Programming Exam Questions page.

Identify and resolve programming logic errors

Use the PUTLOG Statement in the Data Step to help identify logic errors.

Use PUTLOG to write the value of a variable, formatted values, or to write values of all variables.

Use PUTLOG with Conditional logic.

Use temporary variables N and ERROR to debug a DATA step.


data work.ExamScores;
   input Name $ 1-16 Score1 Score2 Score3;
   datalines;
Sullivan, James   86 92 88
Martinez, Maria   95 91 92
Guzik, Eugene     99 98 . 
Schultz, John     90 87 93
van Dyke, Sylvia  98 . 91
Tan, Carol        93 85 85 
;

data work.test;
 set work.ExamScores;
 
 /* Use the PUTLOG Statement in the Data Step to help identify logic errors. */
 if Score1 < 0 or Score2 < 0 or Score3 < 0 then do;
 	/* Use PUTLOG with Conditional logic. */
 	/* Use temporary variables N and ERROR to debug a DATA step. */
 	putlog 'N: ' _N_= 'ERROR: ' _ERROR_=;
	putlog 'ERROR: Invalid score data ' Score1= Score2= Score3=;
    Average = .;
 end;
 else Average = mean(Score1, Score2, Score3);
	
 /* Use PUTLOG to write a warning message to the SAS log. */
 if Average < 92 then
    /* Use PUTLOG to write the value of a variable, formatted values, or to write values of all variables. */
    putlog 'WARNING: Score below the minimum ' name= Average= 5.2;	
run;

proc print data=work.test;
run;

Recognize and correct syntax errors.

Identify the characteristics of SAS statements.

The characteristics of SAS statements involve a sequential number of things such as special characters/operators, keywords and SAS names. The most important thing is all SAS statements end in a semicolon. Also, SAS statements are used to either request information from the SAS system or tell it to perform an operation.

Define SAS syntax rules including the typical types of syntax errors such as misspelled keywords, unmatched quotation marks, missing semicolons, and invalid options.


/* Invalid Options */
options noyear;

data work.syntax;
	/* Misspelled Keywords */
	lenggth Name $3;
	seet sashelp.class;
	
	/* Unmatched Quotation Marks */
	class = 'Maths345;
	
	/* Missing Semicolons */
	output
run;
	
proc print data=work.syntax;
run;

Use the log to help diagnose syntax errors in a given program.

Errors of the work.syntax dataset (above)

Examine and resolve data errors.

Given a SAS program, use the log to determine the reason for a data error.

Suppose, we have the following code:


date test;
   x=1;
run;

proc print data=test
run;

And, if we submitted the code in SAS and observed the log, we will get:

We, see that there is a WARNING that tells that "WARNING 14-169: Assuming the symbol DATA was misspelled as date." which implies the we misspelled the SAS keyword DATA and used the word DATE instead.

Also, there is a SYNTAX ERROR as we can see in the PROC PRINT statement we forgot to put a semicolon right after the dataset 'test' in the PROC print statement as the log tells us.

For more errors check out the SAS documentation here.