Introduction: Programmers sometime perform errors during SAS program coding; these errors are displayed within one of the windows in SAS environment known as log window. These errors usually appear during the compilation and execution phases of SAS programming. Programmers can debug SAS programming errors by understanding processing messages in the SAS log window and then fixing the code spontaneously. The errors are called bugs which are classified as: Syntax: Missing semicolon, uninitialized variable and variable not found Data: Missing values were generated; numeric to character conversion, invalid data, and character field is truncated Logic: DATA step produces wrong results but no error message. Referencing the SAS Log window for errors: The first and most important rule in debugging SAS programs is to always, follow checking the SAS log. After running a SAS program many programmers turn immediately to the output window for a default generated report. This is understandable, but not advisable. It is entirely possible and sooner to get output that looks fine but it might be sometime totally incorrect output report. So often checking the SAS log window whenever a simple program has been run successfully is the only way to know whether a program has run properly or not. A SAS log contains majorly 3 types of messages: errors, warnings and notes. Errors: If a programmer gets an error message in SAS program, programmer will know it because error messages get programmers attention by not at all executing a job with any one of the bugs. Error messages are not quiet, discrete, or subtle; they are the loud, rabble-rousers of SAS messages by stopping a program dead in its tracks. Till the errors are corrected they don’t allow the programmers to move further in programming. For example: ERROR: No CARDS or INFILE statement. Warnings: Warnings are less dire than errors. SAS also prints warnings in log window but then goes ahead and runs the job anyway. Many programmers, including some professional programmers, try to ignore warnings messages. But it should not be ignored because sometimes the situations that result in warnings are indeed harmless; other times they indicate grave problems, if unresolved, will render the results worthless. Programmers should always check all warnings to see if they are harmless or hazardous with the programming. For example: WARNING: The data set WORK.SAMPLE may be incomplete. When this step was stopped there were 0 observations and 3 variables. Different error messages are displayed depending on the error that is generated, some of the error messages that are generated are: Notes: Notes are the most innocuous messages that SAS displays in the SAS log. They simply inform the programmer of the status of their program. Notes contain information such as the number of records inputted from an external file or the number of observations written in a SAS data set. They are critically important way of catching errors. For example: NOTE: The data set WORK.SPECIES has 14 observations and 3 variables. The missing semicolon: Even the newest of SAS programmers knows that every SAS statement ends with a semicolon; so it is ironic that one of the most common bugs is the missing semicolon. While most SAS error messages are clear and easy to understand, the hallmark of a missing semicolon is confusion. Missing semicolons often produce a long stream of baffling messages. For Example: NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.INFILE may be incomplete. When this step was stopped there were 0 observations and 3 variables. Uninitialized variable and variable not found: These two related messages intimate a programmer that SAS was unable to find one of the variables. The first time users if they see one of these messages will probably wonder what SAS is commenting about. When SAS is unable to find a variable in a DATA step, SAS prints the variables uninitialized message. Then SAS creates the variable, sets its values to missing for all observations and runs the DATA step. For Example: NOTE: Variable VAR8 is uninitialized. Numeric to character conversion: If you accidentally mix numeric and character variables, SAS will convert the data from one type to the other, run the program anyway and print the values. Printed values note have been converted to a note in the log window. NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column). Conclusion: A SAS programmer should always check their SAS log even when the output looks fine. Notes are just as important as error messages and warnings in debugging the programs. Understanding an error message and debugging the error can not only help in obtaining a correct analyses report but also help the programmer to improve his SAS programming knowledge and thus help him to perform better in future. Clinnovo is a clinical innovation company. It is pioneer CRO industry in India. Clinnovo offers professional clinical research course , clinical data management course ,SAS Training and imaging training. Clinnovo has been serving different bio-pharma industries across the world with excellence and high quality. For more information contact at +91 9912868928, 040 64635501
Related Articles -
SAS, Environment, Clinical, Data, Errors, Debugging, Handling, Datasteps, Missing values, Program, warning, messages, Programmers, uninitialized, step,
|