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
what is the difference between unique key and primary key? : Sas-di
what versions of sas have you used (on which platforms)? : Sas programming
what is sas business intelligence? : Sas-bi
What do you understand by the term Normal Distribution?
What are the parameters of scan function?
What is the use of divide function?
What is the different between functions and PROCs that calculate the same simple descriptive statistics?
What is the command used to find missing values?
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
What is the function of output statement in a SAS Program?
Tell me more about the parameters in macro? : sas-macro
i have a dataset with 100 obs i want to generate title from 20th obs onwards with total observations. that should contain 100 obs.dont use firstobs and dnt split the data. use dataset block or proc report? how can we genarate;
how can you create zero observation dataset? : Sas programming
what is SAS OPTIMIZATION?
I have a dataset concat having variable a b & c. How to rename a b to e & f?