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.

Chapter 7 Data Structures 131<br />

Lists<br />

Lists<br />

Lists are containers to store items, such as the following:<br />

• numbers<br />

• variables<br />

• character strings<br />

• expressions (for example, assignments (see “Assignments with Lists” on page 132) or function calls)<br />

• matrices<br />

• nested lists<br />

Create a list in one of the following ways:<br />

• use the List function<br />

• use { } curly braces<br />

Examples<br />

Use the List() function or curly braces to create a list that includes numbers and variables:<br />

x = List(1, 2, b);<br />

x = {1, 2, b};<br />

A list can contain text strings, other lists, and function calls:<br />

{"Red", "Green", "Blue", {1, "true"}, sqrt(2)};<br />

You can place a variable into a list and assign it a value at the same time:<br />

Evaluate Lists<br />

x = {a=1, b=2};<br />

When you run a script that contains a list, a copy of the list is returned. The items inside the list are not<br />

evaluated.<br />

b = 7;<br />

x = {1, 2, b, Sqrt(3)};<br />

Show(x);<br />

x = {1, 2, b, Sqrt(3)};<br />

To evaluate items in a list, use the Eval List function.<br />

b = 7;<br />

x = {1, 2, b, Sqrt(3)};<br />

c = Eval List(x);<br />

{1, 2, 7, 1.73205080756888}

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

Saved successfully!

Ooh no, something went wrong!