Showing results for

- Home
- /
- Programming
- /
- Programming
- /
- difference between i and u modifiers?

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

☑ This topic is **solved**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 09-15-2023 04:32 AM
(171 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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 'ab**d**'. Then you get 6 vs. 7 for similar reasons.

2 REPLIES 2

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

```
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

"

Hands-on-Workshop: "

"

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

SAS Documentation

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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 'ab**d**'. Then you get 6 vs. 7 for similar reasons.

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.