To make a string variable’s letters all uppercase in a SAS data step, we can use the SAS upcase() function.

data data_new;
        set data;
        uppercase_word = upcase(word);
run;

When working with strings in our datasets, it can be useful for comparison or display purposes to convert strings to have all uppercase or lowercase letters.

In a SAS data step, we can use the SAS upcase() function to easily convert a string variable to have all uppercase letters.

Let’s we have the following SAS dataset.

data data;
    input word $ 10.;
    datalines;
this
is
a
dataset
with
some
strings.
;
run;

We can easily make all of these strings uppercase with the SAS upcase() function.

data data_new;
        set data;
        uppercase_word = upcase(word);
run;

/* Output: */
  word     uppercase_word
1 this     THIS	
2 is       IS	
3 a        A	
4 dataset  DATASET	
5 with     WITH	
6 some     SOME	
7 strings. STRINGS.

If you’d like to send all letters to lowercase, you can use the SAS lowcase() function. If you want to capitalize the first letter of the string variable and have all other letters lowercase, you can use the SAS propcase() function.

Hopefully this article has been useful for you to learn how to use the SAS upcase() function to convert strings to uppercase in a SAS data step.

Categorized in:

SAS,

Last Update: March 20, 2024