How to Create or Modify a Variable in SAS Programming? Last Updated : 23 Jul, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report This will help you to create or modify a variable. It is common to define a new variable based on the existing variable. Let's create a dataset In the code below, we are creating a dataset named as Example1 which is going to store on WORK(temporary) library. In this dataset, there would be a variable called OldRate which contains a numeric value. The RUN statement is defined to close the dataset program. SQL DATA Example1; OldRate=42; RUN; Output: Creating a numeric variable You can create variables using the form: variable = expression; Suppose you are asked to create a new variable NewRate, in the existing SAS data set Example1. Both variables are numeric. The variable NewRate is twice of OldRate. SQL DATA Example1; SET Example1; NewRate=3*OldRate; RUN; Output: If you are asked to store a new variable NewRate on a new dataset, you can create it using DATA statement. SQL DATA Readin; SET Example1; NewRate=3*OldRate; RUN; In above case, the dataset READIN was created. Creating a character variable In the dataset Example1, let's create a character variable as Type. The character value for the set is set 'GeeksforGeeks'. The quote marks need to be entered around the character variable. SQL DATA Example1; SET Example1; Type = 'GeeksforGeeks'; RUN; Output: Since Type is a character variable, so the value entered should in quotes. It can be either single or double quotes. Creating or Modifying a variable Suppose the value of OldRate is increased by 8 units and you need to calculate the relative change in rate. In this case, we are modifying the existing variable OldRate so we will add 8 to OldRate. later we calculate the percentage change between old and new rate. SQL DATA Readin; SET Example1; OldRate=8 + OldRate; NewRate=OldRate*3; Change= ((NewRate-OldRate)/ OldRate); Format Change Percent10.0; RUN; Output: The FORMAT statement is used to display the changed value in percentage format. Comment More infoAdvertise with us Next Article How to drop variables from a dataset in SAS Programming? S ShubhamMaurya3 Follow Improve Article Tags : Software Engineering SAS Programming Similar Reads How to drop variables from a dataset in SAS Programming? This topic is regarding how to drop variables from a dataset in SAS. It includes various methods to delete variables from data. In SAS, there are two ways to drop variables: DROP = data set option DROP statement Let's start with creating a data set: SQL DATA outdata; INPUT roll_num gender $ class su 2 min read SAS | How to read character of varying length using COLON Modifier We generally face this situation when we have company names or both first and last names of a person in our data set. We can use a colon modifier ":" to tell SAS to read variable "Name" until there is a space or other delimiter. The $30. refers to the variable as a character variable having max leng 2 min read SAS | How to specify a list of Variables? Suppose you have a list of variables. You don't want to type the name of each variable every time to define them within the function or array. You are looking for a shortcut to accomplish this task. Create a dataset with a list of variables SQL data dummy; input a1 a3 a4 a2 a6$ bs$ a5; cards; 2 1 3 2 min read If-Then-Else statement in SAS Programming Comparison Operators used while using conditional statements. Symbol Mnemonic Meaning = EQ equals ^= or ~= NE not equal > GT greater than < LT less than >= GE greater than or equals <= LE less than or equals in IN selecting multiple values IF statement Syntax: IF (condition is true) = 3 min read How to import data into SAS? Entering Data Directly: You can enter numbers of lines of data directly in SAS program by using a DATALINES statement. The keywords are as follows: DATA: The DATA step always starts with a DATA statement. The purpose of the DATA statement is to tell SAS that you are creating a new data set i.e. outd 3 min read Set Variable Data Types in MATLAB There are many cases when a user has to import data into MATLAB script from various files. These file types could be .txt, .xlsx, .csv, .dat, etc. types. Now, each file type has its own method of defining data types. However, for computation purposes, MATLAB requires the data to be of numeric type, 3 min read Like