Annoyances with SAS that Don’t Exist in Ruby

Now, I’m not as extreme as the person who created a SAS Tetris game, (Richard DeVenezia, in case you were wondering) but I still try to do just about everything in SAS,  if only to prove that I can do it.

Why would someone who has been using SAS for 28 years decide to pick up Ruby?  One legitimate reason is just for the hell of it, which is why I do most things. The other reason, though, is you will find that some things in Ruby are very easy that are not so easy in SAS, which makes it a very good complementary language.

For example, how many times have you had problems with a variable that was originally defined as a string somehow, even though that wasn’t what you intended at all. This often happens to me when importing Excel files where someone has typed spaces for missing data or before a number in a field I want to be read as numeric. However it happens, it’s annoying. You can use the input function in SAS to create numeric data from character data. You can create a new variable and add 0 to it and SAS will create a numeric variable. So, there’s ways to get around it. In Ruby, it’s really simple

varname.to_s     —  will change varname to a string variable

varname.to_i  — changes varname to an integer

Then, there are some things that SAS just won’t allow you to do, like mix character and numeric variables in the same array. What if you WANT to do that? Well, Ruby is cool with it.

On the other hand, I haven’t found an easy way to get Ruby to do a logistic regression. So … I am thinking if I find the time to learn Ruby well enough, this may be a match made in heaven, read in and manipulate data easily, then send it out to a file to be analyzed by SAS.

Yes, there are other languages that would do this equally well, or perhaps better, but it’s pretty obvious that Ruby has much wider applicability than just data management. If I am going to go to a great deal of trouble to learn something in depth, it better be usable in a variety of situations. After all, I wouldn’t use SAS that much if it didn’t have a whole lot to offer besides Analysis of Variance.

Similar Posts

5 Comments

  1. A good scripting language saves a lot of time in the long run.

    Personally, I’m using Unix command line tools at the moment (sed, awk, grep etc) as they are small, and work well on my crummy old computer. That being said, I certainly intend to learn more Python in the near future, once the damn doctorate is finally submitted.

  2. We use Ubuntu but the resident rocket scientist was talking about installing a different version on one of the computers, I guess just to see if there was something we’d like better. I like Ubuntu fine, personally.

    It was kind of a toss up between Python and Ruby as to what to learn next, and I just started with Ruby and I liked it.

  3. ruby is one sweet langage. i would not call it a script langage because it is a real proper langage. only one that is more dynamic than say C and the likes.

    I programmed c and c++ professionally, and really appreciate the flexibility of ruby. it allows you to see some higher level concepts that otherwise are hidden (but exists) in other langages.

  4. python has great packages but is massively dirty as a programming langage compared to ruby..

Leave a Reply

Your email address will not be published. Required fields are marked *