Desktop productivity for business analysts and programmers

SQL vs SAS

Reply
New Contributor
Posts: 4

SQL vs SAS

A general question as to whether SQL can do most of what SAS can do as far as data pulls and data manipulation.  More specifically, can SQL replicate the FIRST. LAST. functionality of SAS?

Respected Advisor
Posts: 3,065

Re: SQL vs SAS

In a word no. SQL can't do FIRST. LAST. type processing.

SQL and the DATA step each have their strengths and weaknesses. Which might be the better option depends on what you are trying to do. I use both - remember both are still SAS if you are using PROC SQL.

I tend to use SQL when I want to do lots of table joins with varying join criteria, but then I switch to the DATA step when I want to do complex conditional processing. With SAS you have the advantage of choosing the best tool for the job.

PS: You can sort of fudge  FIRST. LAST. type processing in SQL if you get into SQL cursor processing (available in Oracle, SQL Server and other relational databases), but its really ugly compared with SAS's simplicity.

New Contributor
Posts: 4

Re: SQL vs SAS

Thank you this is exactly what I wanted to know.

Grand Advisor
Posts: 17,411

Re: SQL vs SAS

Data transposes are harder in SQL, not impossible, but harder, especially depending on the flavour/version of SQL you're referring to.

When you're doing analysis row by row it's much much much easier in a data step.

Valued Guide
Posts: 3,206

Re: SQL vs SAS

The SAS data_step is the only part you are taking into account for comparing SQL/SAS? That is very limited one.
SQL was invented for OLTP and it has the limitations and advantages involved for that. SAS was invented for analysis with those limitations and advantages.

You can do al lot in the SAS datastep (pointering) that is not possible with SQL due to the fact SAS is processing all the data sequential and SQL is doing it in subsets. The performance behavior is also totally different.

---->-- ja karman --<-----
New Contributor
Posts: 4

Re: SQL vs SAS

No, but I am working with somewhat novice users and it is all they will probably care about at this point.

Grand Advisor
Posts: 10,233

Re: SQL vs SAS

And to throw a wrench in the data manipulation side SAS has Proc IML for matrix manipulation.

Valued Guide
Posts: 3,206

Re: SQL vs SAS

Ballard and the HASH package within DS2. Many procs  that could be seen as packages and yes with IML you could use R packages . 

---->-- ja karman --<-----
New Contributor
Posts: 4

Re: SQL vs SAS

I am not familiar with IML.  Somewhat familiar with HASH.  Thank you so much for your answers.

Ask a Question
Discussion stats
  • 8 replies
  • 576 views
  • 12 likes
  • 5 in conversation