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

I have a column called "Name" which stores the 8 states and territories in Australia, all upper-cased and spacing replaced with an underscore (i.e. NEW_SOUTH_WALES, VICTORIA, QUEENSLAND, SOUTH_AUSTRALIA, WESTERN_AUSTRALIA, TASMANIA, NORTHERN_TERRITORY, AUSTRALIAN_CAPITAL_TERRITORY). My aim is to create a separate column where the state names are proper case with spacing, so I created 3 individual columns that split the names.

Word1=propcase(scan(Name,1,'_'));
Word2=propcase(scan(Name,2,'_'));
Word3=propcase(scan(Name,3,'_'));

After this step, I used 

Word=cat(Word1,Word2,Word3);

to create the column with space in between. However, it only gives me a blank column instead. How can I resolve this?

Snap10.png

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

You could use:

Word = propcase(translate(Name, ' ', '_'));

Don't forget to use the length-statement so that the length of "Word" is sufficient.

 

View solution in original post

2 REPLIES 2
andreas_lds
Jade | Level 19

You could use:

Word = propcase(translate(Name, ' ', '_'));

Don't forget to use the length-statement so that the length of "Word" is sufficient.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1464 views
  • 0 likes
  • 3 in conversation