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 6 Types of Data 123<br />

Work with Character Functions<br />

Munger<br />

m = expr(mno);<br />

c = Name Expr(m) || "xyz";<br />

show(c);<br />

//result is "mnoxyz"<br />

m=char(expr(mno));<br />

c=m || "xyz";<br />

show(c);<br />

//result is "mnoxyz"<br />

Concat Items() converts a list of string expressions into a single string, with each item separated by a<br />

delimiter. If unspecified, the delimiter is a blank. Its syntax is<br />

resultString = Concat Items ({list of strings}, );<br />

For example,<br />

a = {“ABC”, “DEF”, “HIJ”};<br />

result = Concat Items(a, “/”);<br />

returns<br />

“ABC/DEF/HIJ”<br />

Alternatively,<br />

returns<br />

result = Concat Items(a);<br />

“ABC DEF HIJ”<br />

Munger works many different ways, depending on what you specify for its arguments:<br />

Munger(string, offset, find | length, );<br />

Table 6.7 Munger behaviors for various types of arguments<br />

Find, length, and replace arguments<br />

If you specify a string as the find and specify no<br />

replace string, Munger returns the position (after<br />

offset) of the first occurrence find string.<br />

If you specify a positive integer as the length and<br />

specify no replace string, Munger returns the<br />

characters from offset to offset + length.<br />

If you specify a string as the find and specify a<br />

replace string, Munger replaces the first occurrence<br />

after offset of text with replace.<br />

Example<br />

Munger("the quick brown fox", 1,<br />

"quick");<br />

5<br />

Munger("the quick brown fox",1,5);<br />

"the q"<br />

Munger("the quick brown fox", 1, "quick",<br />

"fast");<br />

"the fast brown fox"

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

Saved successfully!

Ooh no, something went wrong!