Thursday, April 16, 2009

What is _IORC_?

It is short for Input-Output Return code. The definition is at below from SAS online doc:
The automatic variable _IORC_ contains the return code for each I/O operation that the MODIFY statement attempts to perform.

However, it is not quite right. We should get some points for _IORC_:
#1: it is automatic variable, which means it exist in PDV but do not output.
#2: it used with indexed dataset to check whether the direct read found a matching obervation. That means it do make sense in dataset with key= option, no matter what statement is used, e.g. SET statement, MODIFY statement, etc.
#3: it is a good habit to always check _IORC_ after reading indexed dataset. Here is a good example: http://support.sas.com/kb/26/002.html.
#4: since SET statement retain all variable values, we should STOP or re-assign all variables to missing and _ERROR_ to 0 when _IORC_ is not _SOK (no matching observation).

Wednesday, April 8, 2009

conversion from SAS environment variable to library implicitly

It is interesting that a SAS environment variable can be used as a SAS library.
The library should be assigned implicitly.

*sample code;
options noxwait;
options set=test="c:\";
libname test clear; *de-assign the library;
libname test list; *the library appear again;

*In this way, we can define user-defined formats at SAS invocation;
-set fmtlib "format-path"
-fmtsearch (work fmtlib)