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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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