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
List out some key concept of SAS
Describe what are the different levels of administrative users in sas? : sas-grid-administration
why is a stop statement needed for the point=option on a set statement? : Sas programming
How long can a macro variable be? A token? : sas-macro
How do you delete duplicate observations in sas?
What are the differences between proc means and proc summary?
If a variable contains only numbers, can it be a character data type?
what is the difference between infile and input? : Sas-administrator
do you need to know if there are any missing values? : Sas programming
In sas admin differentiate between roles and capabilities? : sas-grid-administration
Explain what is data step?
how does sas handle missing values in formats? : Sas programming
what is SAS OPTIMIZATION?
what is data governance? : Sas-di
What are the 3 components in sas programming?