Hi:
Both PUT and PUTLOG are capable of writing to the SAS log. However PUTLOG will ONLY write to the SAS log. PUT as a statement can also be used to write to an external file. In the program, as shown below the PUT statement is writing to the log and to an external file:
Note that the yellow highlighted statement (PUTLOG) and the cyan highlighted statement (PUT) both write to the SAS log. using NOTE: at the beginning of the text string caused color coding to be implemented in the log. However, PUT, when used with a FILE statement changes the behavior of where the PUT statement writes. The PUT statement that immediately follows a FILE statement writes to the file specified, in this case, c:\temp\writeclass.txt. There are many different formatting things I could have done but did not do.
I have used _N_ and _ERROR_ in PUTLOG statements for debugging. Typically it has happened when I've had a big program (over 500 lines of code) and there was some logic problem that I needed to trace. The place where I used _N_ and _ERROR_ was to dump an entire observation when I encounted an error to see whether there was bad data or whether my program had failed to account for the condition that broke the logic. In the Programming 2 class, we have some examples of using PUTLOG to help you debug a program. If you are studying for certification and using one of the Prep Guides, it may be useful to review the PUTLOG section in Programming 2.
Maybe others will have some examples of when they've used _N_ and _ERROR_ and PUTLOG for debugging.
Cynthia