if i having variables named a b c d e f ,how to find total of
each variable ????give syntax...??

Answers were Sorted based on User's Feedback



if i having variables named a b c d e f ,how to find total of each variable ????give syntax...??..

Answer / shambhu verma

There are various method for it but the simple way to find
out total / sum of each numerical variables is...........

Proc print data= sas data set;
sum var-list;
run;

Is This Answer Correct ?    18 Yes 0 No

if i having variables named a b c d e f ,how to find total of each variable ????give syntax...??..

Answer / puja

Its total of each variable and not row total i suppose
hence the syntax can be given as
proc sql;
create table SUM as
select sum(a) as sum_a,
sum(b) as sum_b,
sum(c) as sum_c,
sum(d) as sum_d,
sum(e) as sum_e,
sum(f) as sum_f
from input_dataset_name;
quit;

Is This Answer Correct ?    8 Yes 3 No

if i having variables named a b c d e f ,how to find total of each variable ????give syntax...??..

Answer / manoj

Or instead of giving all the var-list you can just give:-

Proc print data= sas data set;
sum _numeric_;
run;

It will give sum of all the numeric variable present in the dataset.
Else if you have all the variables as numeric type, then you can give :-

Proc print data= sas data set;
sum _all_;
run;

Is This Answer Correct ?    5 Yes 0 No

if i having variables named a b c d e f ,how to find total of each variable ????give syntax...??..

Answer / naveen

proc print data=qqq;
sum a b c;
or
sum _all_;
run;

Is This Answer Correct ?    1 Yes 0 No

if i having variables named a b c d e f ,how to find total of each variable ????give syntax...??..

Answer / anik chatterjee

The last answer is right but if all the values are missing
then sum function will give a note in log. Best way to add
0 with all value. Hence if all value is missing then total
would be 0 and no note will be there.

proc sql;
create table SUM as
select sum(a) as sum_a,
sum(b,0) as sum_b,
sum(c,0) as sum_c,
sum(d,0) as sum_d,
sum(e,0) as sum_e,
sum(f,0) as sum_f
from input_dataset_name;
quit;

Is This Answer Correct ?    0 Yes 5 No

if i having variables named a b c d e f ,how to find total of each variable ????give syntax...??..

Answer / ak

sum = sum(of a-f);

Is This Answer Correct ?    3 Yes 16 No

Post New Answer

More SAS Interview Questions

Hot to suppress characters from a given string?

4 Answers   CTS,


describe about joins? briefly?

2 Answers   CitiGroup,


How we can create SAS USER DEFINED CODE?

0 Answers  


What are the joins,types of joins and thier functions?

7 Answers   SAS,


What is the difference between %local and %global?

1 Answers  


What do you feel about hardcoding?

3 Answers   Pfizer,


The below code we are using for creating more than one macro variables in proc sql using into clause. How we can use same code to create macro variables vara, varb, varc instead of var1, var2, var3.? proc sql noprint; select count(distinct(patient)) into :var1 - :var3 from dataset1 group by trtreg1c ; quit;

1 Answers   Accenture,


Can we use where and having clauses in a single SAS program. ex: proc sql;     select a,b,c from test      where state in 'KA'      and having <some condition>. Is the above program run correctly, if not why ?     

4 Answers   UHG,


why is sas data integration studio important? : Sas-di

0 Answers  


Explain the message ‘MERGE HAS ONE OR MORE DATASETS WITH REPEATS OF BY VARIABLE’.

2 Answers  


Which is Best Institute for learning SAS BASE & SAS BI in Hyderabad? Can anyone suggest me ?

5 Answers   ACC,


State the difference between INFORMAT and FORMAT ?

0 Answers  


Categories