BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
xxformat_com
Barite | Level 11

Hi,

 

Can you think of any case where the i modifier would give a different result from the u modifier?

- i ignores case

- u adds uppercase letters to the list of characters

 

Just an example with countc, but it could be with any function allowing these modifiers.

data test;
    length x $12;
    x='bca1-abcABC2';

    countc_x_abc_i=countc(x,'abc','i');
    countc_x_abc_u=countc(x,'abc','u');
run;

proc print data=test;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @xxformat_com,

 

Example 1:

 

x='bca1-abcABD2';

Then your COUNTC calls would yield 8 vs. 9 because the second counts the "D" (all uppercase letters were added to the initial list consisting of "a", "b" and "c"), whereas the first does not (only "a", "b", "c", "A", "B" and "C").

 

Example 2:

Leave x unchanged, but change the second argument of the COUNTC calls to 'abd'. Then you get 6 vs. 7 for similar reasons.

 

View solution in original post

2 REPLIES 2
yabwon
Onyx | Level 15
data test;
    length x $12;
    x='bca1-abcABC2';

    countc_x_abc_i=compress(x,'a','i');
    countc_x_abc_u=compress(x,'a','u');
run;

proc print data=test;
run;
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



FreelanceReinh
Jade | Level 19

Hi @xxformat_com,

 

Example 1:

 

x='bca1-abcABD2';

Then your COUNTC calls would yield 8 vs. 9 because the second counts the "D" (all uppercase letters were added to the initial list consisting of "a", "b" and "c"), whereas the first does not (only "a", "b", "c", "A", "B" and "C").

 

Example 2:

Leave x unchanged, but change the second argument of the COUNTC calls to 'abd'. Then you get 6 vs. 7 for similar reasons.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 363 views
  • 2 likes
  • 3 in conversation