what is the meaning of third argument (dks, adks) in FINDC function?
Flag=findc(value,"","dks") Flag2=findc(value,"","adks")
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.
The documentation explains it all:
https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/n1mdh2gvd5potjn14jipysvzn4o7.htm
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.
'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.
@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;
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 letter, not a digit and not a punctuation.
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.
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.
Ready to level-up your skills? Choose your own adventure.