SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 7 replies
  • 5452 views
  • 2 likes
  • 3 in conversation