
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 Certification Course
- Dec 8 2025
- Online
SAS Certification Course
- Dec 9 2025
- Online
SAS Certification Course
- Dec 10 2025
- Online
SAS Course Online Training
- Dec 11 2025
- Online
SAS Course Online Training
- Dec 12 2025
- 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

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

From Student to AI Pro: What Does Prompt Engineering Entail and How Do You Start?
Learn what prompt engineering is, why it matters, and how students and professionals can start mastering AI tools like ChatGPT, Gemini, and Copilot.

Cyber Security in 2025: The Golden Ticket to a Future-Proof Career
Cyber security jobs are growing 35% faster than any other tech field (U.S. Bureau of Labor Statistics, 2024)—and the average salary is $100,000+ per year! In a world where data breaches cost businesses $4.45 million on average (IBM, 2024), cyber secu

SAP SD in 2025: Your Ticket to a High-Flying IT Career
In the fast-paced world of IT and enterprise software, SAP SD (Sales and Distribution) is the secret sauce that keeps businesses running smoothly. Whether it’s managing customer orders, pricing, shipping, or billing, SAP SD is the backbone of sales o

SAP FICO in 2025: Salary, Jobs & How to Get Certified
AP FICO professionals earn $90,000–$130,000/year in the USA and Canada—and demand is skyrocketing! If you’re eyeing a future-proof IT career, SAP FICO (Financial Accounting & Controlling) is your golden ticket. But where do you start? Sulekha IT Serv

Train Like an AI Engineer: The Smartest Career Move You’ll Make This Year!
Why AI Engineering Is the Hottest Skillset Right Now From self-driving cars to chatbots that sound eerily human, Artificial Intelligence is no longer science fiction — it’s the backbone of modern tech. And guess what? Companies across the USA and Can

Confidence Intervals & Hypothesis Tests: The Data Science Path to Generalization
Learn how confidence intervals and hypothesis tests turn sample data into reliable population insights in data science. Understand CLT, p-values, and significance to generalize results, quantify uncertainty, and make evidence-based decisions.