SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
DebG
Obsidian | Level 7

proc fedsql now uses SQL:1999 standards and with that I was hoping to see CTE added.  It is not clear to me if Common Table Expression (CTE) is supported, but I am unable to execute CTE outside of any database.  CTE will let me break down my query into bite size pieces and reuse those pieces.  Expected syntax below for clarity.

 

Does SAS support CTE, will it be coming soon, or have I missed it?

 

proc fedsql;

  create table want as

  (with tmp as (select * from somewhere)

  ,tmp2 as (select * from somewhere_else)

 select a.id, b.var

 from tmp a

 left join tmp2 b

on a.id=b.id

);

quit;

2 REPLIES 2
DebG
Obsidian | Level 7

Appreciated Kirk.  CTE can be completed in passthrough in all databases which are SQL:1999 compliant.  SAS is the the only exception I have found.  I'm specifically interested in completed CTE in SAS datasets.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2207 views
  • 1 like
  • 2 in conversation