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.

484 Extending JMP Chapter 14<br />

Working with <strong>SAS</strong><br />

affect those global connections. However, if there is no active global connection, that global connection is<br />

set to the connection opened by the object.<br />

View <strong>SAS</strong> Libraries<br />

After you connect to a <strong>SAS</strong> server, use the <strong>SAS</strong> Get Lib Ref command to view the libraries on that server:<br />

librefs = <strong>SAS</strong> Get Lib Refs( );<br />

{"BOOKS", "EGSAMP", "GENOMICS", "GISMAPS", "JMPSAMP", "JMPTEST",<br />

"MAILLIB", "MAPS", "OR_GEN", "ORION_RE", "ORSTAR", "<strong>SAS</strong>HELP",<br />

"<strong>SAS</strong>USER", "TEMPDATA", "TSERIES", "V6LIB", "WORK", "WRSTEMP"}<br />

If the library containing the data that you want is not assigned, assign it:<br />

Open <strong>SAS</strong> Data Sets<br />

librefs = <strong>SAS</strong> Assign Lib Refs(“My Library”, “c:\public\data”);<br />

First, assign a <strong>SAS</strong> library reference:<br />

<strong>SAS</strong> Assign Lib Refs(“MyLib”, “c:\public”);<br />

The first argument is any name that you want to use to refer to the library reference. The second is the path<br />

on the server where the data sets are located.<br />

Next, get the list of data sets in the selected library:<br />

datasets=<strong>SAS</strong> Get Data Sets(“MyLib”);<br />

{"ANDORRA", "ANDORRA2", "ANYVARNAME", "BOOKS", "BOOKSCOPYNOT", "BOOKS_VIEW",<br />

"CATEGORIES", "DATETIMETESTS", "MOREUGLY", "NOTTOOUGLY", "PAYPERVIEW",<br />

"PUBLISHERS", "PURCHASES", "PURCHASES_FULL",<br />

Now you can open a data set:<br />

or<br />

or<br />

dt=<strong>SAS</strong> Import Data(“BOOKS”, “PURCHASES”);<br />

dt=<strong>SAS</strong> Import Data(librefs[1], datasets[12]);<br />

dt=<strong>SAS</strong> Import Data(“BOOKS.PURCHASES”);<br />

Once you have a reference to a library, you can get information about any <strong>SAS</strong> data sets in that library. For<br />

example, you can get a list of variables:<br />

bookvars=<strong>SAS</strong> Get Var Names(“BOOKS.PURCHASES”);<br />

{"purchaseyear", "purchasemonth", "purchaseday", "bookid", "catid",<br />

"pubid", "price", "cost"}<br />

With that information, you can choose to import only part of the data set by specifying the variables to<br />

import.<br />

dt=<strong>SAS</strong> Import Data(librefs[1], datasets[12], columns(bookvars[1], bookvars[2],<br />

bookvars[4]));

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

Saved successfully!

Ooh no, something went wrong!