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
PROC Star

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
PROC Star

You could use:

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

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

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

From SAS Users blog
Want more? Visit our blog for more articles like these.
5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

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