14.03.2014 Views

Scripting Guide - SAS

Scripting Guide - SAS

Scripting Guide - SAS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 9 Data Tables 291<br />

Row State Operators<br />

for each row(<br />

rowstate()=combine states(color state(row()), marker state(row())));<br />

And now observe the difference between setting one attribute of a row state:<br />

color of(rowstate(1))=3;<br />

And setting every aspect of a row state to a single state:<br />

// makes row 1 red without changing marker<br />

row state(1)=color state(5); // makes row 1 blue and loses its marker<br />

To copy all the current row states into a row state column:<br />

new column("rscol", set formula(rowstate());<br />

for each row(rscol = rowstate());<br />

To copy several but not all the current row states into a row state column, you would use a script like the<br />

following, commenting out or omitting any states that you do not want.<br />

new column("rscol2", set formula(CombineStates(<br />

ColorState( color of() ),<br />

ExcludedState( excluded() ),<br />

HiddenState( hidden() ),<br />

LabeledState( labeled() ),<br />

MarkerState( marker of() ),<br />

SelectedState( selected() ))));<br />

Note: The current row for scripting is not related to rows being selected (highlighted)<br />

in the data table or to the current cursor position in the data table window. The current<br />

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

Row. For example, Row()=3, but please note that such a setting only lasts for the<br />

duration of that script, and then Row() reverts to its default value, zero, so submitting a<br />

script all at once can produce different results than submitting a script a few lines at a<br />

time.<br />

Another way to establish a current row for a script is to enclose it in For Each Row,<br />

which executes the script once for each row of the current data table.<br />

Throughout this chapter, examples without an explicit current row, such as below,<br />

should be assumed to take place within a context that establishes a current row. For<br />

example, inside For Each Row( ) or after Row()=1.<br />

rowstate()=color state(3);<br />

See “What is the Current Row?” on page 250, for more information.<br />

Combinations of Characteristics<br />

You can get or set many characteristics at once by combining state settings inside Combine States, or you<br />

can get or set each characteristic one at a time, with the ultimate row state being the accumulation of<br />

characteristics. For example, with Big Class, you can set green Y markers for males but for now hide them<br />

in plots, and set red X markers for females and not hide them in plots:<br />

for each row(

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

Saved successfully!

Ooh no, something went wrong!