07-28-2015 10:47 PM
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.
07-28-2015 11:49 PM
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.
07-29-2015 01:58 AM
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.