SAS versus R : using lists

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);


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

Example in R

print ( mean(1:5))
[1] 3

SAS versus R : using lists

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s