From the course: SAS® 9.4 Cert Prep: Part 04 Preparing Data

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Demo: Using expressions to create new columns

Demo: Using expressions to create new columns - SAS Tutorial

From the course: SAS® 9.4 Cert Prep: Part 04 Preparing Data

Demo: Using expressions to create new columns

- [Instructor] Often your data does not have all the columns that you need and you need to calculate or derive new columns from existing columns. Fortunately, this is easy to do with the DATA step. To create new columns, you use an assignment statement. You simply type the name of the new column, an equal sign, and then an expression that creates the new data value. In this example the WHERE statement includes rows where origin is not equal to USA. Remember that SAS is reading data from the cars table one row at a time. The first assignment statement creates the numeric column Profit, and generates a value for every row in the output table by subtracting the value of Invoice from the value of MSRP. The second assignment statement creates a column named Source, and assigns the character string Non-US Cars. Without a KEEP statement, the output table would include all columns, but because there is a KEEP statement…

Contents