Help using Base SAS procedures

Cumulative Sum

Reply
N/A
Posts: 0

Cumulative Sum

I am again posting the same query
since am not getting the desired code

data is as follows
date meter demand cal;
1 A 5 5
2 B 10 15
3 C 15 30
4 D 20 50
5 E 25 75
6 F 30 105
7 G 35 140
8 H 40 180

in this table
there are three variables and "cal" is the result i require
so
i need the code such as i get the cumulative sum as shown in "Cal"
my input are date,meter(charachter) and demand and i need "cal" which
is shown in the table
and i need to sort it by meter and date
like for meter A (date 1 to 8) its "cal"
then meter B (date 1 to 8) its "cal"
so, please do reply if u have an answer for this query
thanks
Super Contributor
Super Contributor
Posts: 3,174

Re: Cumulative Sum

Posted in reply to deleted_user
Explore the use (and output file) for PROC FREQ for this purpose. SAS generates variables with unique names (see the DOC) and so you need only to rename the output variable, if required.

Scott Barry
SBBWorks, Inc.

Base SAS(R) 9.2 Procedures Guide: Statistical Procedures, PROC FREQ
http://support.sas.com/documentation/cdl/en/procstat/59629/HTML/default/freq_toc.htm
Super Contributor
Posts: 281

Re: Cumulative Sum

Posted in reply to deleted_user
In the data step where you read in the data, you need to add one simple command to compute cumulative demand;

CAL+DEMAND;
Super Contributor
Super Contributor
Posts: 3,174

Re: Cumulative Sum

With the DATA step technique, there will be BY variable list and using IF FIRST. considerations - not the case when using the PROC approach.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 3 replies
  • 168 views
  • 0 likes
  • 3 in conversation