• 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
  • Ruby
  • 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 intnx – Add or Subtract Time from Date Variables in SAS Data Step
  • 2.  SAS strip – Remove All Leading and Trailing Blanks from String Variable
  • 3.  SAS call symput – Create Macro Variables in Data Step
  • 4.  SAS Remove Labels from Dataset with PROC DATASETS
  • 5.  SAS Percent Format – Formatting Number as Percent in SAS Dataset
  • 6.  SAS min() Function – Find Minimum Value Across Columns in Data Step
  • 7.  Using SAS to Sum by Group with PROC MEANS
  • 8.  SAS data _null_ – Create a SAS Dataset with No Records and Variables
  • 9.  SAS compress – Remove Whitespace and Characters from String
  • 10.  SAS nodupkey – How to Remove Duplicates with PROC SORT by Key

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

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

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 © 2023 · The Programming Expert · About · Privacy Policy