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 the difference between unique key and primary key? : Sas-di

0 Answers  


Where do you use proc means over proc freq?

0 Answers  


Will it bother you if the guy at the next desk times the frequency and duration of your bathroom or coffee breaks on the grounds that ?you are getting paid twice as much as he is??

0 Answers   Oracle,


What is factor analysis?

0 Answers  


Describe the ways in which you can create macro variables? : sas-macro

0 Answers  


what is the difference between compiler and interpreter? give any one example (software product) that act as a interpreter?

36 Answers   Accenture, College School Exams Tests, CTS, IBM, IHRD, Infosys, Sylhet Engineering College, TCS, Wipro,


what does the run statement do? : Sas programming

0 Answers  


Do you know the features of sas?

0 Answers  


How to convert .xls file into CSV format?

6 Answers   Quintiles,


i have a null dataset with 10 variables; i want to print only name of the varibales in log window and also output window.how can we do this one?

6 Answers   GSK,


In which case u go for libname and in which case u go for proc sql pass thru facilit diff?

1 Answers  


Code a PROC MEANS that shows both summed and averaged output of the data.

5 Answers  


Categories