BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DataScientist
Quartz | Level 8

Hi, in an upcoming engagement I will need to use T-SQL instead of SAS and PROC SQL. Has anyone used T-SQL before? If so, are there any important differences in syntax that might be of value to know beforehand. Also, is there a resource that I can refer to that might show me how a certain query might be written differently in T-SQL compared to PROC SQL.

 

The T-SQL will be used primarily for querying and reporting purposes rather than database administration purposes.

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20
Except from the obvious SAS specifics like functions and formats, there two differences I think is worth mentioning :
- no support for the "remerging summary statics with original data". You need the spicy join the aggregation results back.
- no support for the calculated key word. You need to repeat any formula wich result you wish to use more than once in the same query.
Data never sleeps

View solution in original post

7 REPLIES 7
Reeza
Super User

T-SQL is Microsoft so there's tons of documentation and examples out on the web. 

 

Biggest difference - look into Windowing function 

DataScientist
Quartz | Level 8

Thanks @Reeza. Will look into the difference in the Windowing function.

Reeza
Super User

It's not so much difference as something SAS doesn't have. 

 

 

Reeza
Super User

And Pivot? Or is that Oracle? Look into how they do processing over groups basically, besides group by. 

LinusH
Tourmaline | Level 20
Except from the obvious SAS specifics like functions and formats, there two differences I think is worth mentioning :
- no support for the "remerging summary statics with original data". You need the spicy join the aggregation results back.
- no support for the calculated key word. You need to repeat any formula wich result you wish to use more than once in the same query.
Data never sleeps
DataScientist
Quartz | Level 8

Thank you for your input @LinusH. This is great I'm sure I will learn more along the way. One difference I chanced upon recently was with the AS keyword while assigning Aliases. 

 

The AS keyword is recommended but can be omitted while assigning an Alias in T-SQL.

 

Not having the AS keyword while assigning an Alias in PROC SQL causes an error.

DataScientist
Quartz | Level 8

Another minor difference is while eliminating duplicate rows:

 

The DISTINCT keyword is common between T-SQL and PROC SQL. PROC SQL also has an alternative, the UNIQUE keyword. This, I believe, isn't available in T-SQL.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 3875 views
  • 2 likes
  • 3 in conversation