14.03.2014 Views

Scripting Guide - SAS

Scripting Guide - SAS

Scripting Guide - SAS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

96 JSL Building Blocks Chapter 5<br />

Inquiry Functions<br />

1<br />

Show(Is Scriptable(col));<br />

1<br />

Show(Is Scriptable(plat));<br />

1<br />

Show(Is Scriptable(rep));<br />

1<br />

Is Empty() tests to see whether a variable has a value, a function, an expression, or a reference to an object.<br />

Otherwise, you get errors when referring to something that has not been created or assigned a value yet.<br />

Programmers call this an uninitialized variable.<br />

Here is an example of a test to see whether a data table is opened and therefore assigned to the dt variable. If<br />

a data table is not opened, the Open() function prompts the user to open the table.<br />

If(Is Empty(dt = Current Data Table()),<br />

dt = Open()<br />

);<br />

You can use Is Empty() for any variable (such as global variable, local variable, and columns).<br />

Table 5.5 shows functions that identify object types.<br />

Table 5.5 Inquiry Functions That Identify Object Types<br />

Syntax<br />

Is Associative<br />

Array(x)<br />

Is Empty(global)<br />

Is Empty(dt)<br />

Is Empty(col)<br />

Is Expr(x)<br />

Is List(x)<br />

Is Matrix(x)<br />

Is Name(x)<br />

Is Namespace(x)<br />

Is Number(x)<br />

Is Scriptable(x)<br />

Is String(x)<br />

Explanation<br />

Returns 1 if the evaluated argument is an associative array or 0 otherwise.<br />

Returns 1 if the global variable, data table, or data column does not have a<br />

value (is uninitialized) or 0 otherwise.<br />

Returns 1 if the evaluated argument is an expression or 0 otherwise.<br />

Returns 1 if the evaluated argument is a list or 0 otherwise.<br />

Returns 1 if the evaluated argument is a matrix or 0 otherwise.<br />

Returns 1 if the evaluated argument is a name or 0 otherwise. See “Retrieve a<br />

stored expression, not its result” on page 185 for details.<br />

Returns 1 if the evaluated argument is a namespace or 0 otherwise.<br />

Returns 1 if the evaluated argument is a number or missing numeric value or<br />

0 otherwise.<br />

Returns 1 if the evaluated argument is a scriptable object or 0 otherwise.<br />

Returns 1 if the evaluated argument is a string or 0 otherwise.<br />

Type(x) Returns a string naming the type of x.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!