Sample 26002: Ouput formatted message for _IORC_ values
The IORCMSG function returns the formated error message associated with the current value of the automatic variable _IORC_ . The _IORC_ variable is created when you use the MODIFY statement, or when you use the SET statement with the KEY= option.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/* Create sample data */
data master(index=(x));
input x $ y;
datalines;
apple 12
banana 4
coconut 5
date 7
eggs 9
fig 5
;
data transaction;
input x $ y;
datalines;
coconut 8
grape 8
honeydew 3
;
/* Note that 'grape' and 'honeydew' do not exist in the master data set. */
/* Trying to look up these values in MASTER will result in a non-matching */
/* condition. IORCMSG will write out an error message indicating why the */
/* non-matching condition was generated. */
data updated;
set transaction;
set master key=x;
select (_iorc_);
/* match is found in master */
when (%sysrc(_sok)) do;
output;
end;
when (%sysrc(_dsenom)) do;
/* no match found in master, write out message to log */
_ERROR_=0;
errmsg=IORCMSG();
put errmsg 'Value was ' x +(-1) '.';
end;
end;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/* Partial LOG output */
337 data updated;
338 set transaction;
339 set master key=x;
340 select (_iorc_);
341 /* match is found in master */
342 when (%sysrc(_sok)) do;
343 output;
344 end;
345 when (%sysrc(_dsenom)) do;
346 /* no match found in master, write out message to log */
347 _ERROR_=0;
348 errmsg=IORCMSG();
349 put errmsg 'Value was ' x +(-1) '.';
350 end;
351 end;
352 run;
ERROR: No matching observation was found in MASTER data set. Value was grape.
ERROR: No matching observation was found in MASTER data set. Value was honeydew.
NOTE: There were 3 observations read from the data set WORK.TRANSACTION.
NOTE: The data set WORK.UPDATED has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
Use IORCMSG function to return a formatted error message for unexpected conditions when using KEY= logic.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Functions ==> SAS File I/O
|
| Date Modified: | 2006-01-10 03:02:52 |
| Date Created: | 2006-01-09 11:14:58 |
Operating System and Release Information
| SAS System | Base SAS | All | 8.2 TS2M0 | n/a |