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.

304 Data Tables Chapter 9<br />

Calculations<br />

For the Big Class data set, Col Mean(Height) is 62.55 and Col Std Dev(Height) is 4.24. So for each<br />

row, the formula above would subtract 62.55 from that row’s height value and then divide by 4.24.<br />

Note: The pre-evaluated functions disregard the excluded row state, so any excluded rows are included in<br />

calculations. For summary statistics that obey row exclusion, use the Distribution platform.<br />

Columnwise Functions<br />

The functions whose names begin with “Col” all work columnwise, or down the values in the specified<br />

column, and return a single number. For example, Col Mean(height) finds the mean of the values in all<br />

the rows of the column height and returns it as a scalar result. Some examples:<br />

Rowwise Functions<br />

Average Student Height = Col Mean(height);<br />

Height Sigma = Col Std Dev(height);<br />

The functions without “Col” listed below work rowwise across the values in the variables specified and<br />

return a column result. For example, Mean(height, weight) finds the mean of the height and weight for<br />

the current row of the data table. The rowwise statistics are valid only when used in an appropriate data<br />

table row context. Here are some possibilities:<br />

// scalar result for row 7 assigned to JSL global variable<br />

row()=7; ::scalar = Mean(height, weight);<br />

// formula column created in data table<br />

new column("Scaled Ht-Wt Ratio",<br />

formula(mean(height, weight)/age));<br />

// vector of results<br />

vector=J(1,40); // create a 1x40 matrix to hold results<br />

for each row(vector[row()]=mean(height,weight)); //fill vector<br />

Rowwise functions can also take vector (column matrix) or list arguments:<br />

myMu=mean([1 2 3 4]); mySigma=stddev({1, 2, 3});<br />

Calculator Formulas<br />

JMP enables you to store formulas in columns that are automatically evaluated to create the values in the<br />

cells of the column. If you open the formula, you get a calculator interface to edit the formula structurally.<br />

However, the formula is implemented with JSL, and you can obtain the text JSL form of any expression in<br />

the calculator by double clicking on it. The text can be edited, and when it is defocused, it is compiled back<br />

into the structural form.<br />

There is no difference between a formula column created through the calculator window and one created<br />

directly through JSL with commands such as New Column(..., Formula(...)) or<br />

Col

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

Saved successfully!

Ooh no, something went wrong!