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

What is a put statement?

1156


What does the trace option do?

1067


what is the difference between infile and input? : Sas-administrator

1088


hi tell be about pfizer? how to compare the work with other companies ? please tell me how to login and work also?

2045


What are the differences between proc means and proc summary?

1091


how do you debug and test your sas programs? : Sas programming

1091


Difference between SAS STATA & SPSS?

1082


Explain by-group processing?

960


What is the command used to find missing values?

1060


how sas deals with business intelligence? : Sas-bi

1017


Name any two sas spawners? : sas-grid-administration

999


what is the difference between calculating the 'mean' using the mean function and proc means? : Sas programming

1198


Give e an example of..

2294


How do you use the do loop if you don’t know how many times you should execute the do loop?

1233


How can sas program be validated?

993