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
Can you explain the process of calendar?
What are the differences between sum function and using “+” operator?
Explain the main difference between the sas procedures and functions? : Sas-administrator
What are the prime responsibilities of data integration administrator? : Sas-di
How to read an input file in sas?
What commands are used in the case of including or excluding any specific variables in the data set?
How do you control the number of observations and/or variables read or written? Approximately what date is represented by the SAS date value of 730?
What Proc glm does?
what do the sas log messages "numeric values have been converted to character" mean? What are the implications? : Sas programming
What is the role of sas grid administrator? : sas-grid-administration
What will calendar procedure do?
What do you know about symput and symget?
If you have a dataset that contains 100 variables, but you need only five of those, what is the code to force SAS to use only those variables?
how to do user inputs and command line arguments in sas?
What are the parameters of scan function?