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 / rpd
I can give logic part, rest kindly manage :)
step 1:proc sort the dataset by "PID YEAR"
step2 :in the datastep "SET" it using by PID YEAR
create a temp variable say _SUM and RETAIN _SUM,
reset _SUM=0 on FIRST.YEAR.
T_VALUE=_SUM+VALUE
I guess this will work
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Describe the function and untility of the most difficult SAS macro that you have written.
what are the scrubbing procedures in sas? : Sas programming
What is Linear Regression?
What is data _null_?
What is the SAS data set?
What is the difference between INPUT and INFILE ?
For what purposes have you used sas macros? : sas-macro
what is program data vector? : Sas-administrator
Enlist the functions performed by sas.
What is a put statement?
what are the component of range? : Sas-bi
If you have a dataset that contains 100 variables, but you need only five of those, what is the code to force SAS to use only those variables?
which features do you use to check the data validations and errors? : Sas-administrator
What is the maximum and minimum length of macro variable
how could you generate test data with no input data? : Sas programming