SAS: Character substitution

Source: Internet
Author: User

substr (s,p,n) with the character position command

function: The substitution and extraction of SAS characters.

Grammar:

1. Extract: New=substr (old,p,n)

Start extracting n-length characters from the first character of the variable old, and name it the variable new.

such as: New=substr (old,2,3); old= "ABCDEFG"; new= "BCD";

2. Replacement: substr (old,p,n) = "XXX"

The first character of the variable old is replaced by n characters, and the replacement content is "XXX".

such as: old= "ABCDEFG"; substr (old,2,3) = "123"; then old will become "A123EFG".

Tranwrd/translate (S, "oldxx", "newxx") command with character content

Function: tranwrd: The whole substitution of vocabulary (string) ; translate: bulk substitution of single characters

Grammar:

1. TRANWRD:

old= "St. Baker"; NEW=TRANWRD (Old, "St", "Street"); new= "Street. Baker ";

2. Translate:

Old=123456;new=translate (old, "246", "abc"), new= "1a3b5c";

SAS: Character substitution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.