sqlsasproc-sql

Does SAS Proc SQL allow windowing functionality like Over Partition By


I have standard sql code which I need to use in SAS Proc SQL, however that code contains a lot of iterations of windowing functions like Over Partition By. I wanted to know if SAS allow that if not can I do it in data steps instead.


Solution

  • No, SAS proc sql has never been fully ANSI compliant.

    Your best bet will be to mimic the functionality with first dot and last dot type logic in data step. Here's one example but you'll probably be better off thinking about which type of functionality you need first (rank, row_number, etc.) and then look up the specific data step code you would need to write.

    SAS proc fedsql might be another option but despite it's being closer to ANSI compliant, it doesn't seem to have implemented windowing functionality as of yet.

    If you're pulling data from an RDBMS like ORACLE, SQL Server, etc., you could use SAS sql pass through to take advantage of the native database syntax which will likely have the windowing functionality implemented.