• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • VBA
  • About
You are here: Home / SAS / SAS Proper Case – Capitalize First Letter of Word with propcase Function

SAS Proper Case – Capitalize First Letter of Word with propcase Function

January 24, 2022 Leave a Comment

To capitalize the first letter of a word and make a string variable’s letters all proper case in a SAS data step, we can use the SAS propcase() function.

data data_new;
        set data;
        proper_case_word = propcase(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, all lowercase letters, or all words with the first character capitalized.

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

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 proper case with the SAS propcase() function. The SAS propcase() function will convert the first letter to uppercase and all the other letters to lowercase.

data data_new;
        set data;
        proper_case_word = propcase(word);
run;

/* Output: */
  word     proper_case_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’d like to send all letters to lowercase, you can use the SAS lowcase() function.

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

Other Articles You'll Also Like:

  • 1.  SAS where in – Subset Data by Multiple Values in Data Step
  • 2.  SAS ceil – Round Up to Ceiling of Number in a SAS Data Step
  • 3.  SAS calculated – Use Columns Created from Select in PROC SQL
  • 4.  Concatenating Strings in a SAS Data Step
  • 5.  SAS case when – Conditional Logic with case Expression in PROC SQL
  • 6.  SAS trim – Remove All Trailing Blanks from String Variable in Data Step
  • 7.  Round Number to 2 Decimal Places in SAS
  • 8.  SAS Delete Dataset – Use PROC Datasets to Delete SAS Files
  • 9.  SAS right() Function – Right Align Character Variables in Data Step
  • 10.  SAS Comments – Commenting Your SAS Code the Right Way

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

The Programming Expert is a compilation of hundreds of code snippets to help you find solutions to your problems in Python, JavaScript, PHP, HTML, SAS, and more.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2022 · The Programming Expert · About · Privacy Policy