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.

102 JSL Building Blocks Chapter 5<br />

Name Resolution<br />

Note: The current row in a JSL script is not determined by selecting rows or positioning your cursor in the<br />

row. The current row is defined to be zero (no row) by default. You can set a current row with Row() (for<br />

example, Row() = 3). Please note that such a setting only lasts for the duration of that script. Then, Row()<br />

reverts to its default value, zero. This behavior means that submitting a script all at once can produce<br />

different results than submitting a script a few lines at a time.<br />

Another way to establish a current row for a script is to enclose it in For Each Row(). This method<br />

executes the script once for each row of the current data table. For an example, see “If” on page 87. See<br />

“Data Tables” chapter on page 233 for more information about working with data tables.<br />

Will a Scoping Operator “Stick” to its Name?<br />

Yes. Once you use a scoping operator with a name, that name continues to be resolved accordingly for all<br />

subsequent occurrences of the name. For example, a script might contain a column and a variable named<br />

age. When you declare the global variable age with the scoping operator :: at the beginning of the script,<br />

age is always interpreted as a global variable in the script. The values in the age column are not affected by<br />

the variable.<br />

::age=70;<br />

Open("$SAMPLE_DATA/Big Class.jmp");<br />

age=5; // age is a global variable.<br />

Show(age); // age is still a global variable.<br />

Which Has Precedence When Scoping, ":" or "[ ]"?<br />

Scoping occurs before subscripting. This means that these two lines of code are equal:<br />

dataTable:colName[i]<br />

(dataTable:colName)[i]

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

Saved successfully!

Ooh no, something went wrong!