BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Elliott
Obsidian | Level 7

I need to query a name variable and the user wants to know if the name is only a single word.  The variable contains business names so should have multiple words. How do I do that.. for the specific words I am using index(lowercase(name), "Corp")>0 but I do not know how to query for a singer word, no matter what it is.  The name field is Char 26.

 

Any assistance you can offer will be greatly appreciated.

 

Thanks,

Elliott

1 ACCEPTED SOLUTION

Accepted Solutions
Haris
Lapis Lazuli | Level 10
COUNTW counts words, not characters. CountW(VarName)=1 sounds like the condition you're looking for.

View solution in original post

4 REPLIES 4
Haris
Lapis Lazuli | Level 10
Are you looking for COUNTW function?
Elliott
Obsidian | Level 7

no, I need to identify if the business name is only a single word, no matter how many characters.  The user feels this may be an invalid name and wants to review the information.  They feel a single name with no spaces is an invalid business name and should be flagged.

 

Thanks, 

Haris
Lapis Lazuli | Level 10
COUNTW counts words, not characters. CountW(VarName)=1 sounds like the condition you're looking for.
Reeza
Super User

COUNTW() is correct, please try it and let us know. If it's not, post the code you've tried and show an example of a case it doesn't find.

 


@Elliott wrote:

no, I need to identify if the business name is only a single word, no matter how many characters.  The user feels this may be an invalid name and wants to review the information.  They feel a single name with no spaces is an invalid business name and should be flagged.

 

Thanks, 


 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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