
We may receive data from various sites in clinical studies, and each site may enter data in its preferred format (Upper, Lower Case). We may desire to convert all of our character values to UPCASE, PROPCASE, or LOWCASE when working with such data.
Different internal codes represent uppercase and lowercase values, so you won't get a match if you test for a value like R for a variable when the real value is r. Therefore, before performing any logical comparisons, it is usually beneficial to convert all character values to either uppercase or lowercase.
These three functions change the Case of the argument.
♦ Character case can be changed to Upper or Lower using UPCASE and LOWCASE, respectively.
♦PROPCASE, which stands for "proper case," lowercase the remaining letters, and capitalizes the first character of each "word."
♦ To force the PROPCASE function to capitalize each word, the default delimiter is a space.
The second optional argument to this function is a list of delimiters.
Here is an example
Data _Null_;
SOCTERM=’Cardiac disorders’;
Up_Soc= Upcase (SOCTERM);
Lo_Soc = Lowcase (SOCTERM);
Prop_Soc = Propcase (SOCTERM);
Put Up_Soc = Lo_Soc = Prop_Soc =;
Run;
If we get this data, the task is to create a new dataset that includes the subjects who were randomly assigned to Active Treatment and experienced Adverse Events.
Data Test;
Length Patid 3 Trt $7 AE $10;
Input Patid Trt $ AE $;
Datalines;
101 active nausea 102 placebo no
105 active No 1
08 Active insomnia
109 ACTIVE Dizziness
110 Placebo Bodypain
;
Run;
Converting the cases of both TRT and AE to uppercase Data Modi;
Set Test;
Trtup = Upcase (Trt);
Aeup = Upcase (Ae);
Run;
Data Final (Drop=Trtup Aeup);
Set Modi;
Where Trtup=’ACTIVE’ and Aeup ne ‘NO’;
Run;
ANY FUNCTIONS:
These functions return the first position of ANY DIGIT, ALPHA, ALNUM, PUNCT, or SPACE in the String of characters.
Syntax: ANY***** (String, Startpos);
♦ DIGIT = any digit
♦ ALPHA = any character
♦ ALNUM = any character or digit
♦ PUNCT = any punctuation
♦ SPACE = any space
ANYALNUM FUNCTION:
This function is used to find the position of the first instance of any alphanumeric character, such as an upper- or lowercase letter or number, and return it. The function returns a 0 if none are found. This function can start its search anywhere in the String, if desired, search from right to left by passing in an optional parameter.
Syntax: ANYALNUM (character-value <, start>);
If the start value is positive, the search goes from left to right;
If the value is negative, the search goes from right to left.
Data _Null_;
String = ‘S02-P107 has Nausea’;
ADF1= ANYDIGIT (String);
ADF2= ANYDIGIT (String,6);
ADF3= ANYDIGIT (String,-25);
APF= ANYPUNCT (String);
ASF=ANYSPACE (String);
AAF=ANYALPHA (String);
AANF=ANYALNUM (String);
Put ADF1= ADF2= ADF3= APF= ASF= AAF= AANF=;
Run;
ANYDIGIT (String): ANYDIGIT is a function that takes a string as input and checks if it contains any digits.
It returns true if the String contains at least one digit and false if it does not. This function helps validate input and perform operations based on the presence of digits in a string.
♦ ANYDIGIT (String, 6) ANYDIGIT is a function that checks whether a string contains at least 6 digits.
It returns true if the String contains 6 or more digits and false if it does not. This function helps verify a specific number of digits in a string.
♦ ANYDIGIT (String,-25)The input value "-25" is invalid for the function ANYDIGIT. The function expects a positive integer value as the second parameter to specify the number of digits to check for in the String. Please provide a valid positive integer value for the second parameter.
♦ ANYPUNCT (String)ANYPUNCT is a function that checks whether a given string contains any punctuation characters. Punctuation characters are defined as any character that is not a letter, digit, or whitespace. Examples of punctuation characters include commas, periods, semicolons, hyphens, and brackets.
♦ ANYSPACE (String) The ANYSPACE function determines whether a given string contains whitespace characters. Whitespace characters include spaces, tabs, and newline characters.
♦ ANYALPHA (String) ANYALPHA is a function that checks whether a given string contains at least one alphabetic character. It returns true if the String contains at least one letter and false if it does not. This function helps validate input and ensure that a string contains alphabetic characters.
♦ ANYALNUM (String)The ANYALNUM function checks if a given string contains any alphanumeric characters, including letters and digits. It returns true if the String contains at least one alphanumeric character and false if it does not.
INDEX, INDEXC, AND INDEXW FUNCTIONS
INDEX and INDEXC functions return the position where the char or String of characters first occurs in the String. INDEXW function searches for the entire word.
Syntax:
♦ INDEX (String, Search String)
♦ INDEXC (String, Search String)
♦ INDEXW (String, Search Word)
Data _Null_;
String = ‘THIS IS SASI, A SAS ANALYST’;
Ind_val = INDEX (String, ‘SAS’);
Indc_val = INDEXC (String, ‘SAS’);
Indw_val = INDEXW (String, ‘SAS’);
Put Ind_val = Indc_val = Indw_val =;
Run;
INDEX (String, ‘SAS’) searches for the substring ‘SAS’ in the String and returns the position of Nine (9) when it encounters the String SAS, i.e., in SASI.
INDEXC (String, ‘SAS’) searches the String for either ‘S’ or ‘A’ and returns the position of Four (4) when it first encounters the letter ‘S’. i.e., in THIS
INDEXW (String, ‘SAS’) searches the String for the word ‘SAS’ and returns the position of 17 where if first finds ‘SAS’ i.e., exact word SAS.
FIND, FINDC, AND FINDW FUNCTIONS
The FIND, FINDC, and FINDW functions are used in spreadsheet software, such as Microsoft Excel, to locate the position of a specific character or substring within a cell. The FIND function is used to find the position of a particular character or substring within a cell, while the FINDC function is used to find the position of a case-sensitive character or substring.
The FINDW function finds the position of a specific character or substring within a cell, ignoring any punctuation or white space. These functions are particularly useful for manipulating and analyzing large data sets, as they allow users to quickly and easily locate specific information within a spreadsheet.
Syntax:
♦ FIND (String, Search String, Startpos, Modifier);
♦ FINDC (String, Search String, Startpos, Modifier);
The "modifiers" and "starting position" parameters can be specified using the find function, which likewise looks for a search string within a string. There are two modifiers: "t" and "i." The "t" modifier removes trailing blanks from the String, while the "i" modifier instructs SAS to ignore the Case. SAS is informed of the starting position in the String, indicating where to start.
Data _Null_;
String=’This is SASI, a SAS Analyst’;
Fnd_Val = Find (String, ‘S’);
Fndi_Val =Find (String, ‘S’, ‘i’);
Fndsp_val =Find (String, ‘S’,15);
Put Fnd_Val= Fndi_Val= Fndsp_val=;
Run;
COUNT and COUNTC Functions:
These functions count the occurrences of a String in a bigger character String. ;
Syntax:
♦ COUNT (String, Search String, <Modifier>);
♦ COUNTC (String, Search String, <Modifier>);
Modifiers: I = Ignore Case, T = Remove Leading and Trailing Blanks Data _Null_;
String = ‘Lp lp de lp LP gh lp’;
Nst_Val = COUNT (String, ‘lp’);
Cst_Val = COUNT (String, ‘LP’);
Ict_Val = COUNT (String, ‘lp’, ‘I’);
Ccnt_Val = COUNTC (String, ‘lp’);
Iccnt_Val = COUNTC (String, ‘lp’, ‘I’);
Put Nst_Val = Cst_Val = Ict_Val = Ccnt_Val = Iccnt_Val =; Run;
♦ Nst_Val count all the occurrences of ‘lp’ in the String and hence returns a value
of 3.
♦ Cst_Val count all the occurrences of ‘LP’ in the String and returns a value of 1.
♦ Ict_Val count all the occurrences of ‘lp’ and ‘LP’ due to ‘I’ modifier in the String and hence returns value of 5.
♦ Ccnt_Val count all the occurrences of ‘l’ as well as ‘p’ in the String and hence re- turn the value of 7.
♦ Iccnt_Val count all the occurrences of ‘l’,’L’,’p’, and ‘P’ in the String due to the ‘I’ modifier and hence returns the value of 10.
These are the few character functions of SAS; moreover, in the next blog, we shall discuss the remaining SAS character functions in detail.
In conclusion, the Character Functions of SAS are essential tools for manipulating and analyzing character data. With the ability to extract substrings, concatenate strings, and perform various other operations, SAS users can efficiently and effectively handle character data in their analysis.
By mastering these functions, users can save time and improve the accuracy of their results. Whether you are a beginner or an experienced SAS user, understanding and utilizing these functions can greatly enhance your data analysis skills. So, start exploring the world of SAS character functions today and take your data analysis to the next level!
Find a course provider to learn SAS
Java training | J2EE training | J2EE Jboss training | Apache JMeter trainingTake the next step towards your professional goals in SAS
Don't hesitate to talk with our course advisor right now
Receive a call
Contact NowMake a call
+1-732-338-7323Enroll for the next batch
SAS Course Online Training
- Mar 17 2026
- Online
SAS Course Online Training
- Mar 18 2026
- Online
SAS Course Online Training
- Mar 19 2026
- Online
SAS Course Online Training
- Mar 20 2026
- Online
Related blogs on SAS to learn more

SAS Character Functions Demystified: A Comprehensive Guide
Master the power of SAS character functions and learn how to streamline your data processing tasks.

From Data to Graphs: Harnessing SAS/GRAPH for Effective Analysis
Learn how to effectively analyze and present your data with this comprehensive guide to SAS/GRAPH.

Introduction to SAS/Library
In this blog, we shall discuss introduction to SAS and its library in detail

Importing Data into a SAS Data Set: Effective Methods and Techniques
we have discussed how to import data into SAS data set, best practices for data reading in SAS, and how to create a dataset

Comprehensive Guide to SAS Functions
Learn how to leverage SAS functions to streamline your data analysis and understand the features of SAS functions.

INTRODUCTION TO SAS
We have discussed What is SAS, variables in SAS, six attributes of SAS stores and many other unique concepts of SAS.

SAS to help British Forces to hunt down Nazi Criminals!
As the SAS empowers the professionals to accomplish various success, it has also revealed it’s to open the secrets and postwar exploits helping the government to hunt down the Nazi crime people.

SAS Factory Miner will take your business analysis to next level!
SAS gained significant reach across the globe by providing a reliable platform for advanced statistical analytics. As the more and more organizations grow their need to acquire analytical software, SAS skills

Welcome SAS Factory Miner which takes your business analysis to next level!
SAS gained significant reach across the globe by providing a reliable platform for advanced statistical analytics. As the more and more organizations grow their need to acquire analytical software, SAS

SAS unveils Viya, destined to be the foundation of future products
The ability to analyze, manage and modify data from multiple types of sources makes SAS an unique and popular data analytic software suite in the world. The software suite already become friendly with the non-technical users with its GUI (Graphical U
Latest blogs on technology to explore

Drug Safety & Pharmacovigilance: Your 2026 Career Passport to a Booming Healthcare Industry!
Why This Course Is the Hottest Ticket for Science Grads & Healthcare Pros (No Lab Coat Required!)" The Exploding Demand for Drug Safety Experts "Did you know? The global pharmacovigilance market is set to hit $12.5B by 2026 (Grand View Research, 202

Launch Your Tech Career: Why Mastering AWS Foundation is Your Golden Ticket in 2026
There’s one skill that can open all those doors — Amazon Web Services (AWS) Foundation

Data Science in 2026: The Hottest Skill of the Decade (And How Sulekha IT Services Helps You Master It!)
Data Science: The Career that’s everywhere—and Nowhere Near Slowing Down "From Netflix recommendations to self-driving cars, data science is the secret sauce behind the tech you use every day. And here’s the kicker: The U.S. alone will have 11.5 mill

Salesforce Admin in 2026: The Career Goldmine You Didn’t Know You Needed (And How to Break In!)
The Salesforce Boom: Why Admins Are in Crazy Demand "Did you know? Salesforce is the 1 CRM platform worldwide, used by 150,000+ companies—including giants like Amazon, Coca-Cola, and Spotify (Salesforce, 2025). And here’s the kicker: Every single one

Python Power: Why 2026 Belongs to Coders Who Think in Python
If the past decade was about learning to code, the next one is about coding smarter. And in 2026, the smartest move for any IT enthusiast is learning Python — the language that powers AI models, automates the web, and drives data decisions across ind

The Tableau Revolution of 2025
"In a world drowning in data, companies aren’t just looking for analysts—they’re hunting for storytellers who can turn numbers into decisions. Enter Tableau, the #1 data visualization tool used by 86% of Fortune 500 companies (Tableau, 2024). Whether

From Student to AI Pro: What Does Prompt Engineering Entail and How Do You Start?
Explore the growing field of prompt engineering, a vital skill for AI enthusiasts. Learn how to craft optimized prompts for tools like ChatGPT and Gemini, and discover the career opportunities and skills needed to succeed in this fast-evolving indust

How Security Classification Guides Strengthen Data Protection in Modern Cybersecurity
A Security Classification Guide (SCG) defines data protection standards, ensuring sensitive information is handled securely across all levels. By outlining confidentiality, access controls, and declassification procedures, SCGs strengthen cybersecuri

Artificial Intelligence – A Growing Field of Study for Modern Learners
Artificial Intelligence is becoming a top study choice due to high job demand and future scope. This blog explains key subjects, career opportunities, and a simple AI study roadmap to help beginners start learning and build a strong career in the AI

Java in 2026: Why This ‘Old’ Language Is Still Your Golden Ticket to a Tech Career (And Where to Learn It!
Think Java is old news? Think again! 90% of Fortune 500 companies (yes, including Google, Amazon, and Netflix) run on Java (Oracle, 2025). From Android apps to banking systems, Java is the backbone of tech—and Sulekha IT Services is your fast track t