Solved
Contributor
Posts: 66

# SAS Function

Is there a SAS function that extracts only the numerals from a straing

For example

if   F is a sas function then it should give,

F(1bhy688%<2) = 16882,

F( " 1    5   abc  6 ^* +-? ")=156  and so on    ?

Thanks.

Accepted Solutions
Solution
‎12-08-2012 11:21 PM
Super Contributor
Posts: 1,636

## Re: SAS Function

yes. example:

data have;

input abc \$;

cards;

ewg356

57ugh

f7h58sh5

;

data want;

set have;

new=compress(abc,,'kd');

proc print;run;

All Replies
Solution
‎12-08-2012 11:21 PM
Super Contributor
Posts: 1,636

## Re: SAS Function

yes. example:

data have;

input abc \$;

cards;

ewg356

57ugh

f7h58sh5

;

data want;

set have;

new=compress(abc,,'kd');

proc print;run;

Contributor
Posts: 66

## Re: SAS Function

Great help....I was doing all sort of inefficient coding to fix this!

PROC Star
Posts: 1,317

## Re: SAS Function

In the spirit of sharing at Christmas, for my fellow Canadians, this is EXACTLY the function needed to get %\$##\$#%% gas pumps in the U.S. to accept your credit card. When they ask for a ZIP code, enter your Postal Code, digits only, followed by zeroes to fill to five digits. For example, my postal code is K2P 1S3, I use 21300, it's worked at least ten times on my recent trip. Another small aggravation eliminated, the coincidence of this appearing on the forum the day I get home is quite something.

Merry Christmas, (and even to Americans who create these U.S.-centric applications),

Tom

PROC Star
Posts: 8,171

## Re: SAS Function

: They are probably only collecting the zipcodes for market research purposes and apparently not checking them for validity.  There is no 23100 zipcode in the US.  The closest I could find (using Google) was:

21300 ZIP Code in France - Find ZIP Code all around the world

PROC Star
Posts: 1,317

## Re: SAS Function

No, this has been causing us grief for years. Before we found this, we had tried many options. They were all rejected, which meant going into the gas station, getting them to turn on the pump, usually leaving our credit card with them, and a whole bunch or rigamarole. The following DON'T work:

Using our postal code, with the numbers for the letter keys;

Using 00000;

Using the actual ZIP code of the place we were going.

Based on the last, clearly some kind of edit against our credit card information was being done.

Believe me, someday you'll thank me for this!

Tom

PROC Star
Posts: 8,171

## Re: SAS Function

: I'll try it the next time I'm in the US and will let you know if it worked.  If it does, yes, I will be thanking you profusely!

🔒 This topic is solved and locked.