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

Answers were Sorted based on User's Feedback



how to add distinctly var variable values ex.. Data a; input var; datalines; 0 1 2 3 -1 ..

Answer / karthik

data a;
input var;
cards;
0
1
2
3
-1
-2
-3
;
data report;
set a;
if var>=0 then var1=var;
else var2=var;
drop var;
run;
/*Report output*/
proc print data=report;
run;

Is This Answer Correct ?    4 Yes 1 No

how to add distinctly var variable values ex.. Data a; input var; datalines; 0 1 2 3 -1 ..

Answer / ravikumar marappan

data test;
input var;
retain sub;
retain ad;
if var < 0 then sub=sum(sub,var);
else ad=sum(ad,var);
datalines;
1
2
3
-1
-2
-3
;
run;

Is This Answer Correct ?    4 Yes 2 No

how to add distinctly var variable values ex.. Data a; input var; datalines; 0 1 2 3 -1 ..

Answer / 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

how to add distinctly var variable values ex.. Data a; input var; datalines; 0 1 2 3 -1 ..

Answer / arun kumar

proc sql;
create table arun as
select sum(case when var>=0 then var else . end) as num_p,
sum(case when var<0 then var else . end) as num_n
from a;
quit;

proc print;
run;

Is This Answer Correct ?    0 Yes 0 No

how to add distinctly var variable values ex.. Data a; input var; datalines; 0 1 2 3 -1 ..

Answer / mahesh babu b

data test1;
set a;
if find(var,'-') >0 then b=var;
else c=var;
run;

Is This Answer Correct ?    3 Yes 5 No

Post New Answer

More SAS Interview Questions

what is portability of sas programmes?

2 Answers   Capital One,


The Lion King is hosting an animal conference. All the animals in the world attend except one. Which animal does not attend?

6 Answers   Oracle,


What are the main differences between sas versions 8.2, 9.0, 9.1?

4 Answers  


what is intially documentation for a sas programmer?

2 Answers   Accenture,


What is the purpose of _character_ and _numeric_?

0 Answers  


what are several options for creating reports in web report studio? : Sas-bi

0 Answers  


Are you involved in writing the inferential analysis plan? Tables specfications?

0 Answers  


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

0 Answers   Accenture, Quintiles,


what is function of retain statment

0 Answers   PPD,


What is Transaction...? And what are Comment, Roll back n Save point..?

2 Answers  


what r the job openings SAS for fresher graduates !

0 Answers   TetraSoft, Wipro,


Do you need to know if there are any missing values?

0 Answers  


Categories