how to add distinctly var variable values ex..
Data a;
input var;
datalines;
0
1
2
3
-1
-2
-3
;
run;
adding all +ve value in one varibale n do the same for -ve
too
Answer Posted / ashish
data a;
input num;
cards;
1
2
3
-5
-7
-8
9
10
0
-56
-3
;
run;
data b ;
retain sum_n sum_p;
set a end=last;
if _n_=1 then sum_n = 0;
if _n_=1 then sum_p = 0;
if(num<0) then sum_n= sum(sum_n,num);
else sum_p= sum(sum_p,num);
if last then output;
run;
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is a put statement?
What does the trace option do?
what is the difference between infile and input? : Sas-administrator
hi tell be about pfizer? how to compare the work with other companies ? please tell me how to login and work also?
What are the differences between proc means and proc summary?
how do you debug and test your sas programs? : Sas programming
Difference between SAS STATA & SPSS?
Explain by-group processing?
What is the command used to find missing values?
how sas deals with business intelligence? : Sas-bi
Name any two sas spawners? : sas-grid-administration
what is the difference between calculating the 'mean' using the mean function and proc means? : Sas programming
Give e an example of..
How do you use the do loop if you don’t know how many times you should execute the do loop?
How can sas program be validated?