I have an extensive background in Base SAS and SAS suite of tools. But R is fairly new to me and I’ve been studying it in my spare time. I figure the best way to learn R is to compare it with SAS. I have SAS University Edition and RStudio on my personal laptop.

For this first blog, I will start with lists in SAS. Lists allow a series of number to be mentioned in a simplified manner in a function. For example, if I want to find an average of 1, 2, 3, 4 and 5, I don’t have to mention all these numbers in the “mean” function. I can use “of” in the function to specify the list.

**Example in SAS**

*data temp;*

*array t{5} (1 2 3 4 5);*

*avg_num=mean( of t1-t5);*

*run;*

R is even easier. It took me just one line to compute the mean.

**Example in R**

* print ( mean(1:5))*

*[1] 3*

### Like this:

Like Loading...