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 use of divide function?
Can you execute macro within another macro? If so, how would sas know where the current macro ended and the new one began? : sas-macro
What do you know about sas data set?
what is function of retain statment
State the difference between INFORMAT and FORMAT ?
Differentiate between ceil and floor functions.
How do you connect the desktop application to metadata server? : sas-grid-administration
What is the role of sas grid administrator? : sas-grid-administration
How would you define the end of a macro?
what is the difference between floor and ceil functions in sas? : Sas-administrator
What is the maximum and minimum length of macro variable
For a user to have access to a standard workspace server, is internal authentication alone is sufficient? : sas-grid-administration
Explain the use of proc print and proc contents?
Mention some common errors that are usually committed in sas programming.
Explain substr function?