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.

82 JSL Building Blocks Chapter 5<br />

Iterate<br />

Example<br />

What does First() do in the following script?<br />

x = 1000;<br />

First(x, x=2000)<br />

The First function returns the value of x (1000). 2000 is then assigned to x.<br />

Iterate<br />

JSL provides the For(), While(), Summation(), and Product() functions to repeat (or iterate) actions<br />

according to the conditions that you specify.<br />

Note: A similar function called For Each Row() is for iterating actions over rows of a data table. See “If”<br />

on page 87 for an example. “Accessing Values” on page 248 in the “Data Tables” chapter also describes<br />

iterating through table rows.<br />

For<br />

The For() function expects four arguments separated by commas. The first three arguments are rules for<br />

how many times to repeat the loop, and the fourth is what to do each time the loop is executed.<br />

The basic syntax for For() is as follows:<br />

For(initialization, while, iteration, body);<br />

For example, the following script sums the numbers from 0 to 20:<br />

s = 0;<br />

For(i = 0, i

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

Saved successfully!

Ooh no, something went wrong!