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

HI All, 

I have base SAS, E.G., SAS Studio, and 

Need to search a large document for all acronyms (2, 3, 4 character), isolate them, and create a table of definitions.

The acronyms can be any character like "IND", "mg", 'USP", etc...

Is there a SAS function , or combination of functions, that will count the number of characters in a word,  and provide a YES/NO (1/0) answer if a certain number of characters are present?  

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

It's easy to count the number of characters in a word:

 

n_characters = lengthn(varname);

 

I'm not sure you gain anything by translating this into a YES/NO.  You can easily select a subset that you want:

 

if n_characters = 3;

 

or

 

if 0 < n_characters < 3;

 

or anything else that you would select.  Possibly:

 

proc freq data=have;

tables varname;

where (0 < lengthn(varname) < 3);

run;

View solution in original post

2 REPLIES 2
Astounding
PROC Star

It's easy to count the number of characters in a word:

 

n_characters = lengthn(varname);

 

I'm not sure you gain anything by translating this into a YES/NO.  You can easily select a subset that you want:

 

if n_characters = 3;

 

or

 

if 0 < n_characters < 3;

 

or anything else that you would select.  Possibly:

 

proc freq data=have;

tables varname;

where (0 < lengthn(varname) < 3);

run;

rmacarthur
Pyrite | Level 9

This works like a charm, Very intersting, 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

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1723 views
  • 0 likes
  • 2 in conversation