BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rnmishra
Calcite | Level 5

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(>%$123abc77 bad guy 88)= 1237788,

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

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

yes. example:

data have;

input abc $;

cards;

ewg356

57ugh

f7h58sh5

;

data want;

  set have;

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

  proc print;run;

View solution in original post

6 REPLIES 6
Linlin
Lapis Lazuli | Level 10

yes. example:

data have;

input abc $;

cards;

ewg356

57ugh

f7h58sh5

;

data want;

  set have;

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

  proc print;run;

rnmishra
Calcite | Level 5

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

TomKari
Onyx | Level 15

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

art297
Opal | Level 21

: 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

TomKari
Onyx | Level 15

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

art297
Opal | Level 21

: 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!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 778 views
  • 2 likes
  • 4 in conversation