SAS: How to check if a sub-string is present on a char variable in SAS?

This is a very common use case where we need to write code to check if a substring is present on a character variable in SAS. That substring can be a character string, a character, or any special character. Depending on the outcomes you can perform your specific operations.  You can achieve this by using … Read more

The FIND Function in SAS (FIND v/s FINDC v/s FINDW)

The FIND function in SAS searches for a specific substring in a given string or character variable and returns the position of its first occurrence.  The FIND function is mostly used where any specific character, keyword, or phrase you want to identify, and/or extract. It is especially helpful when you read raw, scattered, and long … Read more

The Index Function in SAS (INDEX v/s INDEXC v/s INDEXW)

The index function searches the specified string, from left to right in the given string and returns the position of the first character in the string. If there are multiple occurrences of a specified string, the index function returns the first position of the first occurrence and ignores the rest of the occurrences.  The index … Read more

SAS: How to Convert Character Date to Numeric Date in SAS

In this article we have already seen how you can convert char variable to numeric and numeric variable to character variable. When it comes to DATE in SAS, it’s a bit different because SAS has its own date format and informats. You can use the INPUT() function to convert a character date to a numeric … Read more

SAS: How to Use Datalines Statement (Cards/Lines) to Create a SAS Data set

The Datalines statement along with the INPUT statement is used to create a data set from scratch by entering data directly in the program, rather than data stored in an external file. You can use only one DATALINES statement in a DATA step. Use separate DATA steps to enter multiple sets of data. Basic Syntax … Read more

PROC SQL: How to ALTER table and UPDATE columns in SAS Data Set

The ALTER TABLE statement is used to add new variables, delete existing variables, or modify format of variables.  This method gives you more flexibility while adding new variables or modifying existing ones. It is also possible to add values on those newly added columns with UPDATE TABLE statement. The following example demonstrates that two new … Read more

How to Convert ALL Character Variables into Numeric Variables in SAS Data set

You have a SAS data set with few numeric variables and most of them are character variables. Now you want to convert those character variables into numeric variables in the SAS data set.  In this article we have covered how to convert numeric variables into character variables and vice versa. In this article you’ll learn … Read more