Source data is created directly within the SAS script using the DATALINES statement. A single variable, 'Number', is defined and populated with a series of numerical values.
1 Code Block
DATA STEP Data
Explanation : This block is a DATA step that creates a 'sumexample' dataset. It reads the 'Number' variable from internal data lines (DATALINES). The 'CUMSUM' variable is calculated using a sum statement (CUMSUM + Number;), which allows it to accumulate the sum of 'Number' values for each observation, thereby generating a cumulative sum. 'CUMSUM' is automatically initialized to zero for the first record and retains its value from one iteration to the next.
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.