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

How to Convert Character to Numeric Variable in SAS

In this article we’re going to deep dive into the most common question from SAS users. I’m sure you also have the same question on how to convert variable values from character to numeric in SAS. On multiple occasions you do need to perform the data value conversion especially when you’re reading data from different … Read more

How to Convert Numeric to Character Variable in SAS

In this article we’re going to deep dive into the most common question from SAS users. I’m sure you’re also wondering how to convert variable values from numeric to character in SAS. On multiple occasions you do need to perform the data value conversion especially when you’re reading data from different sources. The multiple sources … Read more

INTNX Function in SAS –to Calculate The Last Day of The Last Month

SAS has a really interesting function known as INTNX. You can use this function to control the dates and get desired value by passing proper arguments in the INTNX function. SAS INTNX Function: The INTNX function increments a date, time, or datetime value by intervals such as DAY, WEEK, QTR, and MINUTE, or a custom … Read more