During the testing and debugging stages of developing your application, you'll want to write out a lot of error messages to help find problem areas, and keep statistics on the number of times certain code blocks are being executed (or values are being imputed). You may begin to notice that you're using the same error message in several places. Rather than write out the message every time it's needed, you can define it once and refer to it whenever needed. For example, suppose you have the following error message scattered throughout your code:
errmsg("Current age after imputation is %d", AGE);
Why bother retyping it each time? You can simply define it once and reference it over and over. To do so, select the Message tab in the Message View. You will see one line that has been generated for you; it reads: /* Application ... message file generated by CSPro */. Beneath this simply add your error message (we'll give it number 100001):
100001 Current age after imputation is %d
Then, whenever you want to use this message in your code, simply use the message number:
Besides simplifying your work, after you run your program, a convenient summary statistic will be generated for each user-defined error message, indicating how often it was used. A sample listing is shown below:
Number Freq Pct. Message text Denom
------ ---- ---- ------------ -----
100001 1 - Current age after imputation is %d -
See the
errmsg function for a detailed explanation of all the options available to you.