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.

108 Types of Data Chapter 6<br />

Date-Time Functions and Formats<br />

Use your path variable as you would other variables. The following expression opens the myimportdata.txt<br />

file in the c:/ directory.<br />

Open("$root/myimportdata.txt")<br />

As with getting path variables, omit the dollar sign when setting path variables.<br />

Relative Paths<br />

If you plan to use relative paths in variables, you must set the default directory. Then any path not preceded<br />

by a drive letter is relative to the default directory. Here is an example:<br />

Set Default Directory("c:/users/smith/data");<br />

To return the value of the default directory, use Get Default Directory().<br />

Get Default Directory(); // returns "c:/users/smith/data"<br />

So the following expression:<br />

Open("cleansers.jmp");<br />

resolves as C:/users/smith/data/cleansers.jmp.<br />

File Path Separators<br />

In JMP, the preferred file path format is the Portable Operating System Interface (POSIX), or UNIX,<br />

format with forward slashes (/) as separators. This means that you do not have to identify the current<br />

operating system in scripts run on both Windows and Macintosh. However, each host still accepts its native<br />

format for compatibility.<br />

You can a convert file path format from Windows to POSIX (and vice versa) using Convert File<br />

Path(). Converting from a POSIX to a Windows path might be useful when you need to output a path to<br />

a file or to another application. The syntax is:<br />

Convert File Path (path, , , );<br />

For example, the following script converts a POSIX path to a Windows path:<br />

Convert File Path("c:/users/smith", windows); //returns c:\users\smith<br />

You can substitute a path variable (such as $HOME) for the path inside quotes.<br />

Date-Time Functions and Formats<br />

A date-time value consists of any portion of a date or time. The value can be seconds (3388594698), a<br />

complete date (such as “Wednesday, May 18, 2011”), the date and time (“05/18/2011 8:18:18 PM”), the<br />

week number (3), and so on.<br />

JMP lets you convert date-time values to common formats, perform arithmetic on the values, and<br />

manipulate the data in a number of ways.

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

Saved successfully!

Ooh no, something went wrong!