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

Which function is used to count the number of intervals between two sas dates?

570


how to remove duplicates using proc sql?

630


How do you add a number to a macro variable? : sas-macro

545


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

1727


What are the functions which are used for character handling functions?

620






Have you used macros? For what purpose you have used? : sas-macro

561


describe the interaction table in sas di? : Sas-di

595


What are the statements that are executed only?

674


explain the use of % includes a statement in sas? : Sas-administrator

549


please can you tell me that in companies sas work are doing by through sas coding or sas wizard ??

1667


Describe the function and utility of the most difficult SAS macro that you have written?

2026


What is data _null_?

699


How to test the debugging in sas?

610


What is the order of application for output data set options, input data set options and SAS statements?

1082


What is the purpose of trailing @ and @@? How do you use them?

613