Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Give e an example of..

2105


What is PDV?

1162


what is business intelligence? : Sas-bi

1068


Describe what are the different levels of administrative users in sas? : sas-grid-administration

1041


what is the limit of the number of the rows and columns available in the worksheet? : Sas-bi

1093


What does P-value signify about the statistical data?

1368


what is the Population you used in your project, is it ITT or PP?

2749


What is maximum number of rows and cols can be handled in SAS?

1593


How do you delete duplicate observations in sas?

1077


What are the implications?

1720


What is the use of %include statement?

1065


How do you debug and test your SAS programs?

1566


what do you mean by data staging area? : Sas-di

1144


how to read the variables in sas? : Sas-administrator

1025


explain what is data set in sas? : Sas-administrator

992