BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10

Hi Good Eveyone

 

How to find cumulative sum for height in class library 

using proc sql

data dsn;
set sashelp.class;
run;

proc sort data=dsn;
by age;
run;

data dsn1;
set dsn;
by age;
retain cumulative 0.;
if first.height then height+cumulative;
else  cumulative+height;
run;
5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

If you simply want a cumulative sum of heights and do not want to consider by-groups, then no by-statement is needed in the data step. Simply do

 

proc sort data=sashelp.class out=dsn;
    by age;
run;

data want;
    set dsn;
    cumulative+height;
run;

 

 

BrahmanandaRao
Lapis Lazuli | Level 10

i want using proc sql sort by age variable  and output cumulative sum of height

PeterClemmensen
Tourmaline | Level 20

Why? So much easier with the data step

BrahmanandaRao
Lapis Lazuli | Level 10

Hi draycut 

its just do for homework 

Kurt_Bremser
Super User

Dead simple:

  • create table
  • select age
  • also select sum(height) as cumulative
  • from sashelp.class
  • group by age

Build the SQL code by following the hints, and let us see what you come up with.

As already stated in another thread, I will not insult your intelligence by spoon-feeding you this very simple exercise.

 

PS a home exercise is for you to solve. If you can't, there's three possibilities:

  • you don't have what it takes for the course; drop out of the course and do something you're equipped for
  • you did not follow your teacher properly; be more attentive in the future
  • your teacher is not capable; take the course from someone else

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 844 views
  • 0 likes
  • 3 in conversation