BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
blueskyxyz
Lapis Lazuli | Level 10

Is there a funtion to captalize the first letter and terminology, the prepositionis and articles are in lower case?

 

example: 

var='aids is one of the sexually transmitted diseases'

 

a funtion is called wordcase to adjust the letter capitallization automatically.

 

wordcase(var)='AIDS is one of the Sexually Transmitted Diseases'

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

The closest SAS function is function propcase.

To post-process a string to your needs, you can do something like this:

data T;
  V1='aids is one of the sexually transmitted diseases'
  V2=propcase(V1); 
  V2=prxchange('s/\b(AIDS|NATO|POTUS)\b/\U\1\E/i'          , -1, V2);
  V2=prxchange('s/\b(is|are|one|of|with|the|at)\b/\L\1\E/i', -1, V2);
run;

V2=AIDS is one of the Sexually Transmitted Diseases

 

View solution in original post

5 REPLIES 5
ChrisNZ
Tourmaline | Level 20

The closest SAS function is function propcase.

To post-process a string to your needs, you can do something like this:

data T;
  V1='aids is one of the sexually transmitted diseases'
  V2=propcase(V1); 
  V2=prxchange('s/\b(AIDS|NATO|POTUS)\b/\U\1\E/i'          , -1, V2);
  V2=prxchange('s/\b(is|are|one|of|with|the|at)\b/\L\1\E/i', -1, V2);
run;

V2=AIDS is one of the Sexually Transmitted Diseases

 

blueskyxyz
Lapis Lazuli | Level 10

hi @ChrisNZ  , thanks.

 

the array, and some functions, and regEx functions can solve the letter capitallization, hope a new function can do it directly in the future.

 

 

ChrisNZ
Tourmaline | Level 20

> hope a new function can do it directly in the future.

That won't happen. Every user has a different set of words and logic to process in a specific manner.

Astounding
PROC Star

You will need a computer that speaks English.  After all, how do you treat:

 

Pfizer transmitted its data about ABC, a new drug that aids in treatment of AIDS, a Sexually Transmitted Disease

 

One "aids", one "AIDS", one "transmitted", one "Transmitted"

blueskyxyz
Lapis Lazuli | Level 10
hope there is a new function can do it directly in the future.
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
  • 1568 views
  • 1 like
  • 3 in conversation