AnyUpper, AnyLower, and NoTupper

As their names suggest, the first two functions look for any upper- and lowercase characters, respectively. The third function checks whether any character in the string is not in uppercase. All three of them return the position of the first character that matches the condition.

With all three functions, you can specify a start position as an argument. The rules for the start position are as follows (http://support.sas.com/documentation/onlinedoc/91pdf/sasdoc_913/base_lrdictionary_10307.pdf):

The functions return a value of zero when either of the following occurs:

Let's try and test the functions on the Cars dataset in the following code block:

Data Case_Test;
Set Cars;
Upper_Pos = AnyUpper(Make);
Lower_Pos = AnyLower(Make);
Tupper_Pos = NoTupper(Make);
Run;

The following output shows the number of characters identified in each case:

The Upper_Pos variable has a value of 1 as the AnyUpper function has found that the first letter is in uppercase in all three observations. The Lower_Pos variable has the value 2 for the first observation as the second letter is in lowercase. In the third observation, the variable has a value of 0 since there are no lowercase letters. The NoTupper function worked just like AnyLower and produced the same values for the first two observations of Tupper_Pos just as in the values for Lower_Pos. However, for the third observation, Tupper_Pos has a value of 4. Even though no lowercase was found, the position of the end of the characters in the Make variable was output.