SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5

data s ;
input a1-a3 ;
cards ;
5 10 5
10 20 10
;

proc sql ;
select avg(a1) as average from s ;
quit;

or 

proc sql ;
select avg(of a1-a3) as average from s ;
quit;

 

by using proc sql i got average either column wise or row wise .

how to calculate average in datastep block?

5 REPLIES 5
andreas_lds
Jade | Level 19

@thanikondharish wrote:

data s ;
input a1-a3 ;
cards ;
5 10 5
10 20 10
;

proc sql ;
select avg(a1) as average from s ;
quit;

or 

proc sql ;
select avg(of a1-a3) as average from s ;
quit;

 

by using proc sql i got average either column wise or row wise .

how to calculate average in datastep block?


The syntax for calculating row-wise average is not that different from the proc sql code. If you need to calculate column-wise average, using proc summary is most-times more efficient.

thanikondharish
Calcite | Level 5
proc summary gives mean value.

there is difference between average and mean value i think so.
is there any difference between average and mean value?
andreas_lds
Jade | Level 19

At least in FedSQL functions avg and mean are the same:

avg_function.PNG

 

ballardw
Super User

@thanikondharish wrote:
proc summary gives mean value.

there is difference between average and mean value i think so.
is there any difference between average and mean value?

Only difference in general is spelling and how pedantic some users may be for vocabulary choices. Some uses of "average" have an interpretation of "typical" but in calculations average=mean for SAS. Of course "mean" can be used for "unkind".

 

Unless you are discussing  geometric mean compared to arithmetic mean.

Reeza
Super User

@thanikondharish wrote:


is there any difference between average and mean value?

NO. 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 6566 views
  • 2 likes
  • 4 in conversation