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

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

5184


What is the difference between one to one merge and match merge? Give an example.

813


How will you react when, while consulting a SAS documentation manual to get an answer to a problem, someone says hey, I thought you were supposed to know all that stuff already, and not have to look it up in a book?

2184


What is program data vector (pdv)?

848


If money were no object, what would you like to do?

2902


Difference between informat and format?

850


Name and describe few sas character functions that are used for data cleaning in brief.

878


Explain the use of proc print and proc contents?

730


What is a method to debug and test your SAS program?

981


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

795


What are the features of SAS?

788


Differentiate between format and informat? : sas-grid-administration

799


Give some ways by which you can define the variables to produce the summary report (using proc report)?

833


What is the basic structure of a sas program?

808


why is sas data integration studio important? : Sas-di

775