Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Scan Function to pull out text strings

Status
Not open for further replies.

jamesadams

Programmer
Jun 3, 2010
1
GB
Hi There. New to the forum so please forgive the basic question.

I have a variable and want to use the scan (I think) to pull out the account code. For example;

"Company ABC {1-7VF-244}"

I want to pull out the "1-7VF-244".

The company names are all of different length. All of the account numbers are the same lenght and format and all contained in those {} brackets.

Thanks.
 
If you're sure that the data always appears the way you have described then you could use the scan function like so...
Code:
accountno = scan(Code,2,'{}');

This presumes that the string you mentioned resides in the variable named CODE. Of course you can also use the perl regex in SAS 9.x and up.

Good luck
Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top