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 / ravi s

it need two steps

step 1 : proc sort; by year name;run;

Step 2: data total (drop = value);
set count_;
by year name;
if first.name then T_value =0 ;
T_value + value;
if last.name then output ;
run;

Note: Hence i am doing work in data step. i need to sort
the data first by using "Proc Sort".

Kindly let me know is the any other method to do?

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is SAS OPTIMIZATION?

1817


How substr function works in sas?

701


Describe the function and untility of the most difficult SAS macro that you have written.

1562


What are the 3 components in sas programming?

727


Do you need to rearrange the order of the data for the report?

1837






what is the difference between: x=a+b+c+d; and x=sum (of a, b, c ,d);? : Sas programming

609


Give some examples where proc report’s defaults are different than proc print’s defaults?

600


Mention what is the difference between nodupkey and nodup options?

595


What is the difference between class statement and by statement in proc means?

659


: and & modifiers.

862


WHAT IS SAS WEB SERVICE and what are the steps to create an xml service ?

2266


How do you debug and test your SAS programs?

1048


what is sas application server, database server, sas olap server and sas metadata server? : Sas-di

553


How would you identify a macro variable?

653


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

4914