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


Please Help Members By Posting Answers For Below Questions

how does sas handle missing values in assignment statements? : Sas programming

786


What is the difference between input and infile statement?

878


What is SAS informats?

843


what is sas data set?

863


What are all the problems you faced while validating tables and reports?

3224


what are all the reports you generated in your recent project?

1948


Do you know the features of sas?

803


what are the new features included in the new version of sas i.e., Sas 9.1.3? : Sas programming

773


how to debug and test the sas program? : Sas-administrator

778


What is the differnce between SDTM 3.1.2 to 3.1.1 version

4828


What are the statements that are executed only?

903


How we can call macros with in data step? : sas-macro

831


how does sas handle missing values in a merge? : Sas programming

771


What are the parameters of scan function?

846


what is the difference between unique key and primary key? : Sas-di

828