- DD
SAS VERSUS R : USING LISTS
I've an extensive background in SAS suite of tools. But R is fairly new to me and I’ve been studying it in my spare time. I figured the best way to learn R is to compare it with SAS. I've SAS University Edition and RStudio installed in my personal laptop.
For this article, I'll start with lists in SAS. Lists allow various numbers to be addressed 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 just specify the range of 1 to 5 as shown below for both SAS and R.
Example in SAS
data temp;
array t{5} (1 2 3 4 5);
avg_num=mean( of t1-t5);
run;
Example in R
print ( mean(1:5))
[1] 3
In R, it took me just one line to compute the mean.