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

what is the meaning of third argument (dks, adks) in FINDC function?

 

Flag=findc(value,"","dks")
Flag2=findc(value,"","adks")
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

The third argument specifies any modifiers you want to apply to the function. These modifiers are common to the FIND* family of SAS functions and related functions like COUNT* and string manipulation functions like COMPRESS.

 

Use modifiers to narrow or control the characters that would fit your "find" operation. Want to find just digits? Use 'd'. Want to find digits and punctuation? Use 'dp'. The k modifier inverts the pattern, ex: 'dpk' means find anything except digits and punctuation.

 

So in your example, 'dks' means "any character except digits and space".

 

Related: these functions with modifiers are somewhat easier to understand than using regular expressions (supported in the PRX* family of functions) -- but if you love regex and want that flexibility, use those.

 

And there are simpler functions in the ANY* family of functions for specific patterns, like ANYALNUM to find the first alphanumeric character in a string, or NOTALNUM to find the first that's not an alphanumeric character.

 

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!

View solution in original post

6 REPLIES 6
ChrisHemedinger
Community Manager

The third argument specifies any modifiers you want to apply to the function. These modifiers are common to the FIND* family of SAS functions and related functions like COUNT* and string manipulation functions like COMPRESS.

 

Use modifiers to narrow or control the characters that would fit your "find" operation. Want to find just digits? Use 'd'. Want to find digits and punctuation? Use 'dp'. The k modifier inverts the pattern, ex: 'dpk' means find anything except digits and punctuation.

 

So in your example, 'dks' means "any character except digits and space".

 

Related: these functions with modifiers are somewhat easier to understand than using regular expressions (supported in the PRX* family of functions) -- but if you love regex and want that flexibility, use those.

 

And there are simpler functions in the ANY* family of functions for specific patterns, like ANYALNUM to find the first alphanumeric character in a string, or NOTALNUM to find the first that's not an alphanumeric character.

 

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
David_Billa
Rhodochrosite | Level 12
I can understand the meaning of 'dks' now. What is 'adks' then?

ChrisHemedinger
Community Manager

'a' adds alphabetic characters, so 'adks' is "any character except alpha, digit, space" -- so punctuation, underscore, etc would match. These modifiers are listed in the SAS documentation for each of the functions, which @PaigeMiller linked to for FINDC.

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
David_Billa
Rhodochrosite | Level 12

@ChrisHemedinger I just ran the below step and got the value as 1 and 3 for the variables lag1 and lag2. How it is 1 and 3?

 

data test;
value="he_l l456#o";
lag1=findc(value,"","dks");
lag2=findc(value,"","adks");
run;
Kurt_Bremser
Super User

In the first call, the letter "h" is the first character that is not a digit and not a punctuation.

In the second call, the underline is the first character that is not a letternot a digit and not a punctuation.

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

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
  • 6 replies
  • 2192 views
  • 5 likes
  • 4 in conversation