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.

 

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

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.

 

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
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.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1250 views
  • 5 likes
  • 4 in conversation