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
Give e an example of..
What is PDV?
what is business intelligence? : Sas-bi
Describe what are the different levels of administrative users in sas? : sas-grid-administration
what is the limit of the number of the rows and columns available in the worksheet? : Sas-bi
What does P-value signify about the statistical data?
what is the Population you used in your project, is it ITT or PP?
What is maximum number of rows and cols can be handled in SAS?
How do you delete duplicate observations in sas?
What are the implications?
What is the use of %include statement?
How do you debug and test your SAS programs?
what do you mean by data staging area? : Sas-di
how to read the variables in sas? : Sas-administrator
explain what is data set in sas? : Sas-administrator