BookmarkSubscribeRSS Feed
thanikondharish
Fluorite | Level 6

DATA S ;
NAME='ROITNCV42365672-908$#&^*(#$' ;
NEW=COMPRESS(NAME,'24' ,'KD') ;
RUN;

 

I WANT TO KEEP ONLY DIGITS AND WITH IN DIGITS I DON'T NEED 2,4 NUMBERS .

IS ABOVE PROGRAM CORRECT ? 

USE OF SECOND ARGUMENT?

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

TRY PRESSING THE CAPS LOCK BUTTON, ITS OFFENSIVE TO BE SHOUTED AT!!

 

You need two compress statements, inner to keep digits, outer to remove 2 and 4:

data s;
  name='ROITNCV42365672-908$#&^*(#$';
  new=compress(compress(name," ","kd"),'24');
run;

 

 

thanikondharish
Fluorite | Level 6
USE OF " " AFTER THE VARIABLE NAME
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

You do not read others replies completely.  STOP using all UPPERCASE.  YOU are shouting at us.

 

Reeza
Super User

@thanikondharish you're probably aware but this is a community forum, everyone answering your questions is likely exactly like you either studying at school or working a full time job. There are some SAS employee's on here, but they're identified as such as well. Please take the time to properly format your questions and to mark them solved when someone has taken the time to answer it. 

 

@VDD This is an entirely optional activity, so my solution is to not engage/respond further 😉

Tom
Super User Tom
Super User

Probably easier to just list the digits you want to keep.

compress(xxx,'01356789','k')

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1361 views
  • 2 likes
  • 5 in conversation