How can I convert strings to uppercase, lowercase, and proper case using the SAS programming language? 2

How can I convert strings to uppercase, lowercase, and proper case using the SAS programming language?

SAS (Statistical Analysis System) is a powerful programming language commonly used for data analysis and management. One of its features is the ability to convert strings to different cases, including uppercase, lowercase, and proper case. This can be achieved using the functions UPCASE, LOWCASE, and PROPCASE respectively. These functions allow for easy manipulation of text data, making it convenient to perform various operations on strings within SAS programs. Overall, the availability of these functions adds to the versatility and efficiency of the SAS programming language.

SAS: Convert Strings to Uppercase, Lowercase & Proper Case


You can use the following methods to convert strings to uppercase, lowercase, and proper case in SAS:

Method 1: Convert String to Uppercase

new_string = UPCASE(old_string);

Method 2: Convert String to Lowercase

new_string = LOWCASE(old_string); 

Method 3: Convert String to Proper Case

new_string = PROPCASE(old_string); 

The following examples show how to use each method with the following dataset in SAS:

/*create dataset*/
data original_data;
    input team $1-20;
    datalines;
Washington wizards
Houston rockets
Boston celtics
San antonio spurs
Orlando magic
Miami heat
;
run;

/*view dataset*/
proc printdata=original_data;

Example 1: Convert Strings to Uppercase

The following code shows how to create a new dataset in which all of the team names are converted to uppercase:

/*create new dataset*/data new_data;
    set original_data;
    team = UPCASE(team);
run;/*view new dataset*/
proc printdata=new_data;

Notice that each of the team names have been converted to uppercase.

Example 2: Convert Strings to Lowercase

The following code shows how to create a new dataset in which all of the team names are converted to lowercase:

/*create new dataset*/data new_data;
    set original_data;
    team = LOWCASE(team);
run;

/*view new dataset*/
proc printdata=new_data;

Notice that each of the team names have been converted to lowercase.

Example 3: Convert Strings to Proper Case

The following code shows how to create a new dataset in which all of the team names are converted to proper case:

Note: Proper case means the first letter of each word is capitalized.

/*create new dataset*/data new_data;
    set original_data;
    team = PROPCASE(team);
run;

/*view new dataset*/
proc printdata=new_data;

Notice that each of the team names have been converted to proper case.

Additional Resources

The following tutorials explain how to perform other common tasks in SAS:

Cite this article

stats writer (2024). How can I convert strings to uppercase, lowercase, and proper case using the SAS programming language?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-convert-strings-to-uppercase-lowercase-and-proper-case-using-the-sas-programming-language/

stats writer. "How can I convert strings to uppercase, lowercase, and proper case using the SAS programming language?." PSYCHOLOGICAL SCALES, 1 Jul. 2024, https://scales.arabpsychology.com/stats/how-can-i-convert-strings-to-uppercase-lowercase-and-proper-case-using-the-sas-programming-language/.

stats writer. "How can I convert strings to uppercase, lowercase, and proper case using the SAS programming language?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-convert-strings-to-uppercase-lowercase-and-proper-case-using-the-sas-programming-language/.

stats writer (2024) 'How can I convert strings to uppercase, lowercase, and proper case using the SAS programming language?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-convert-strings-to-uppercase-lowercase-and-proper-case-using-the-sas-programming-language/.

[1] stats writer, "How can I convert strings to uppercase, lowercase, and proper case using the SAS programming language?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, July, 2024.

stats writer. How can I convert strings to uppercase, lowercase, and proper case using the SAS programming language?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top