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 9 Data Tables 237<br />

Data Table Basics<br />

End Of Field (Tab|Space|Comma|Semicolon|Other|None)<br />

EOFOther ("char")<br />

End Of Line (CRLF|CR|LF|Semicolon|Other)<br />

EOLOther ("char")<br />

Strip Quotes|Strip Enclosing Quotes (Boolean)<br />

Labels|Table Contains Column Headers (Boolean)<br />

Year Rule|Two digit year rule ("10-90"| "19xx"| "20xx"| Custom)<br />

Column Names Start|Column Names are on line (number)<br />

Data Starts|Data starts on line (number)<br />

Flags (number)<br />

Custom Rule (name)<br />

Lines to Read<br />

Use Apostrophe as Quotation Mark<br />

For example,<br />

or:<br />

open("c:\test.txt", End of Field(comma), Labels(0),<br />

columns(studentName=character(12), age=numeric(14)));<br />

open("c:\test2.txt", End of Field(Other), EOFOther ("|"), Labels(1),<br />

columns(studentName=character(12), age=numeric(14)));<br />

The options for Open:<br />

Column names and lengths You can specify column names, types, and field widths with a Columns<br />

argument. For example, columns(studentName=character(12), age=numeric(14)) in the<br />

example above.<br />

Note that if you specify settings for a column other than the first column in the file, you must also<br />

specify settings for all the columns that precede it. For example, You want to open a text file that has<br />

four columns, Name, Sex, Age, and ID, in that order, and you want to set Age to numeric(2). You<br />

must also set Name and Sex, and you must list them in the same order:<br />

columns(Name=character(15), Sex=character(1), Age=numeric(2))<br />

You are not required to specify the settings for any columns that follow the one that you want to set.<br />

Strip Quotes Boolean. Specifies whether to remove quotation marks from string values.<br />

When saving spreadsheet-style data in text format, most programs, including JMP, enclose string values<br />

inside double quotation marks ( " ). This ensures that when another program imports the text file, any<br />

spaces, tabs, or commas that are meant to be part of a string value are not misinterpreted as field<br />

delimiters. For example, a string value such as John Doe would be interpreted as two separate strings,<br />

John and Doe, if space were the field delimiter. But "John Doe" inside quotation marks would be<br />

interpreted as a single string, because when most programs including JMP read a quotation mark, they<br />

disregard any delimiter characters and keep reading until they encounter the second quotation mark.<br />

However, since you do not usually want those double quotation marks to be part of the value (for<br />

example, you want John Doe, not "John Doe", in the data table), JMP provides an option Strip<br />

Quotes. If you choose this option, JMP respects the quotation mark rules but removes the marks from<br />

the values.

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

Saved successfully!

Ooh no, something went wrong!