Manipulating Data

Overview

In the previous example, you read in the data set admit and used the WHERE statement in the DATA step to subset the data. For any data set you read in, you can use any of the programming features of the DATA step to manipulate your data.
For example, you can use any of the statements and data set options that you learned in previous chapters.
Manipulating Data Using the DATA Step
To do this...
Use this type of statement...
Subset data
if resthr<70 then delete;  
if tolerance='D';
Drop unwanted variables
drop timemin timesec;
Create or modify a variable
TotalTime=(timemin*60)+timesec;
Initialize and retain a variable Accumulate values
 retain SumSec 5400; sumsec+totaltime; ...

Get SAS Certification Prep Guide: Base Programming for SAS 9, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.