BookmarkSubscribeRSS Feed
BPS
Calcite | Level 5 BPS
Calcite | Level 5

Hi 

I want to pad spaces between a word 
Ex : Mumbai  should be converted to = 'M u m b a i'

Please help.

2 REPLIES 2
collinelliot
Barite | Level 11

You might need to modify this to deal with any specific requirements.

 


data _null_;
    word = 'Mumbai';
    word_pad = strip(prxchange('s/(\w)/\1 /i', -1, word));
    put _all_;
run;
ballardw
Super User

If you actually insert space characters you need to make sure that the length of the variable will hold all of the inserted spaces. To modify an existing data set variable that would involve a LENGTH statement before the SET statement to overwrite the characteristic of the variable brought in with the SET statement.

 

Is this for a specific word or list of words or every value of a variable?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 2 replies
  • 885 views
  • 0 likes
  • 3 in conversation