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 are the applications primarily used by business analyst? : Sas-bi

0 Answers  


What are the 3 components in sas programming?

0 Answers  


Name statements that are recognized at compile time only?

6 Answers  


What do you feel about hardcoding?

1 Answers  


What is _n_?

23 Answers   Accenture,


what are different analysis datasets you created and what are the new variables created

2 Answers   Sciformix,


Name statements that are execution only.

4 Answers  


In proc transpose and data step with arrays which one you pick?

0 Answers   Accenture, Quintiles,


I need to find the numeric field which contains blank in between..Ex:123 456...there is blank in between the 123 456..I need to know if there is any SAS function to find a field.. Please suggest...

5 Answers   TCS,


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

0 Answers  


Is the physical structure of the data set in the same orientation as the report? Do you need to reshape the data sets? What method should you use to reshape the data–DATA steps,PROC TRANSPOSE,output data set from a procedure?

0 Answers  


Please, anyone, let me know the style or an example of using 'by='/'by' variable of a PDV(Program Data Vector)

3 Answers   Verinon Technology Solutions,


Categories