calculate the sum of value using only DATA STEP.
data count_;
input year name $ value;
cards;
2006 xxx 10
2007 yyy 12
2006 xxx 20
2008 yyy 15
2007 xxx 15
;

out put should be like this
year name T_value
-----------------------
2006 xxx 30
2007 xxx 15
2007 yyy 12
2008 xxx 15

Answer Posted / aaa

PROC SORT DATA=COUNT_;
BY YEAR NAME;
RUN;

DATA TEST (DROP=VALUE);
SET COUNT_;
BY YEAR NAME;
RETAIN COUNT;
IF FIRST.NAME THEN COUNT = 0;
COUNT = COUNT + VALUE;
IF LAST.NAME THEN OUTPUT;
RUN;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the difference between unique key and primary key? : Sas-di

589


what versions of sas have you used (on which platforms)? : Sas programming

574


what is sas business intelligence? : Sas-bi

582


What do you understand by the term Normal Distribution?

570


What are the parameters of scan function?

614






What is the use of divide function?

600


What is the different between functions and PROCs that calculate the same simple descriptive statistics?

1222


What is the command used to find missing values?

588


hi all, I need the SAS DI DUMP(A00 260) for attending the certification. if any one have, pls provide it.Please Email to vrpotluri@hotmail.com. Thanks - Ramana

4905


What is the function of output statement in a SAS Program?

606


Tell me more about the parameters in macro? : sas-macro

584


i have a dataset with 100 obs i want to generate title from 20th obs onwards with total observations. that should contain 100 obs.dont use firstobs and dnt split the data. use dataset block or proc report? how can we genarate;

1960


how can you create zero observation dataset? : Sas programming

629


what is SAS OPTIMIZATION?

1813


I have a dataset concat having variable a b & c. How to rename a b to e & f?

574