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 / nani
proc sort data=a;
by year ;
run;
data total ;
set a;
retain T_value;
by year ;
if first.year then T_value =0 ;
T_value + value;
if last.year then output ;
run;
proc print ;
run;
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Describe a time when you were really stuck on a problem and how you solved it?
How would you code a merge that will write the matches of both to one data set, the non-matches from the left-most data?
Which command is used to perform sorting in sas program?
explain the proc in sas? : Sas-administrator
what is the use of proc sql? : Sas programming
What is the order of application for output data set options, input data set options and SAS statements?
for what purpose would you use the retain statement? : Sas programming
What are the difference between the sas data step and sas procs?
explain what is data set in sas? : Sas-administrator
What are SAS/ACCESS and SAS/CONNECT?
What do the PUT and INPUT functions do?
what is the primary data source for the wrs? : Sas-bi
what is the difference between: x=a+b+c+d; and x=sum (of a, b, c ,d);? : Sas programming
Name types of category in which SAS Informats are placed?
Explain data_null_?