To make a string variable’s letters all lowercase in a SAS data step, we can use the SAS lowcase() function.
data data_new; set data; lowercase_word = lowcase(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 lowcase() function to easily convert a string variable to have all lowercase 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 lowercase with the SAS lowcase() function.
data data_new; set data; lowercase_word = lowcase(word); run; /* Output: */ word lowercase_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 uppercase, you can use the SAS upcase() 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 lowcase() function to convert strings to lowercase in a SAS data step.