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
Which function is used to count the number of intervals between two sas dates?
how to remove duplicates using proc sql?
How do you add a number to a macro variable? : sas-macro
Describe the function and untility of the most difficult SAS macro that you have written.
What are the functions which are used for character handling functions?
Have you used macros? For what purpose you have used? : sas-macro
describe the interaction table in sas di? : Sas-di
What are the statements that are executed only?
explain the use of % includes a statement in sas? : Sas-administrator
please can you tell me that in companies sas work are doing by through sas coding or sas wizard ??
Describe the function and utility of the most difficult SAS macro that you have written?
What is data _null_?
How to test the debugging in sas?
What is the order of application for output data set options, input data set options and SAS statements?
What is the purpose of trailing @ and @@? How do you use them?