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.

572 JSL Syntax Reference Appendix A<br />

Character Functions<br />

Substitute Into(string, substring, replacementString, ...)<br />

Substitute Into(list, listItem, replacementItem, ...)<br />

Substitute Into(Expr(sourceExpr), Expr(findExpr), Expr(replacementExpr),<br />

...)<br />

Description<br />

This is a search and replace function, identical to Substitute() except in place. It searches for a<br />

specific portion (second argument) of the source (first argument), and replaces it (third argument). The<br />

first argument must be an L-value.<br />

If a string, finds all matches to substring in the source string, and replaces them with the<br />

replacementString.<br />

If a list, finds all matches to listItem in the source list, and replaces them with the<br />

replacementItem.<br />

If an expression, finds all matches to the findExpr in the sourceExpr, and replaces them with the<br />

replacementExpr. Note that all expressions must be enclosed within an Expr() function.<br />

Arguments<br />

string, list, sourceExpr A string, list, or expression in which to perform the substitution.<br />

substring, listItem, findExpr A string, list item, or expression to be found in the source<br />

string, list, or expression.<br />

replacementString, replacementItem, replacementExpr A string, list item, or<br />

expression to replace the found string, list item, or expression.<br />

Substr(string, start, length)<br />

Description<br />

Extracts the characters that are the portion of the first argument beginning at the position given by the<br />

second argument and ending based on the number of characters specified in the third argument. The<br />

first argument can be a character column or value, or an expression evaluating to same. The starting<br />

argument and the length argument can be numbers or expressions that evaluate to numbers.<br />

Example<br />

This example extracts the first name:<br />

Substr("Katie Layman", 1, 5);<br />

The function starts at position 1, reads through position 5, and ignores the remaining characters, which<br />

yields “Katie.”<br />

Trim("text")<br />

Description<br />

Produces a new character string from its argument, removing any trailing blanks.<br />

Uppercase(string)<br />

Description<br />

Converts any lower case character found in the quoted string to the equivalent uppercase character.

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

Saved successfully!

Ooh no, something went wrong!