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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1229 views
  • 0 likes
  • 2 in conversation