Log function in SAS – LOG, LOG2, LOG10

In order to calculate Log values in SAS we will be using LOG Function. LOG Function in SAS consist of LOG, LOG2, LOG10 Function. LOG2 Function in SAS. LOG10 Function in SAS. Let’s see an example of each.

  • LOG Function in SAS – Log of the column in SAS.
  • LOG10 Function in SAS – Log10 of the column in SAS.
  • LOG2 Function in SAS – Log2 of the column in SAS.

So we will be using EMP_DET Table in our example

Log function in SAS - LOG, LOG2,LOG10 1

 

 

 LOG function in SAS – SYNTAX

LOG(column)

 The following statements illustrate the LOG function:

Log function in SAS - LOG, LOG2,LOG10 2

LOG Function in SAS – LOG()
LOG() Function in SAS takes column as argument and converts column to logarithmic value


data EMP_DET1; 
set EMP_DET; 
LOG_salary = LOG(salary_in_USD); 
run;

So the resultant table with logarithmic value will be

Log function in SAS - LOG, LOG2,LOG10 3

 

 

LOG2 function – Syntax

LOG2(column)

 The following statements illustrate the LOG2 function:

Log function in SAS - LOG, LOG2,LOG10 4

LOG2 Function in SAS – LOG2()
LOG2() Function in SAS takes column as argument and converts column to log value to the base 2.


data EMP_DET1; 
set EMP_DET; 
LOG2_salary = LOG2(salary_in_USD); 
run; 

So the resultant table with logarithmic base 2 value will be

Log function in SAS - LOG, LOG2,LOG10 5

 

 

LOG10 function – Syntax

LOG10(column)

The following statements illustrate the LOG10 function:

LOG10 Function in SAS – LOG10()
LOG10() Function in SAS takes column as argument and converts column to log value to the base 10.



data EMP_DET1; 
set EMP_DET; 
LOG10_salary = LOG10(salary_in_USD); 
run;


So the resultant table with logarithmic base 10 value will be

Log function in SAS - LOG, LOG2,LOG10 7

 

                                                                                         

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.

    View all posts