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
if you were told to create many records from one record, show how you would do this using array and with proc transpose? : Sas programming
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
How do you control the number of observations and/or variables read or written?
how to remove duplicates using proc sql?
Enlist the syntax rules followed in sas statements.
What are the data types that sas contain?
how will you location sas platform applications available from web browser? : Sas-bi
How to create an external dataset with sas code?
what is the purpose of _error_? : Sas programming
What are the different operating system platforms in which we can use sas? : sas-grid-administration
Which command is used to save logs in the external file?
what is metadata? : Sas-bi
What will calendar procedure do?
What is the maximum length of the macro variable? : sas-macro
what is sas olap server? : Sas-di