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

What can you do in a Data Step that you can't do in PROC SQL and vice versa? What are situations where you would prefer one over the other (when is it best to use PROC SQL and when is it best to use the Data Step)? Thank you in advance for your input.

1 ACCEPTED SOLUTION

Accepted Solutions
SAS_inquisitive
Lapis Lazuli | Level 10

A simple google search  (proc sql and data step comparing) gives this paper.

 

http://www2.sas.com/proceedings/sugi29/269-29.pdf

 

Also, @PGStats offers this summary:

Programming level

In proc SQL, you describe what you want and let the procedure figure out the way to do it.

In a data step, you describe what operations must be done, in detail, to get what you want.

 

Data structure

In proc SQL, tables are sets (unordered). Join operations are defined in terms of the cartesian product.

In a data step, datasets are sequences of records. Merge and update operations require prior sorting.

 

Summaries

In proc SQL, a limited group of summary functions can accumulate information about subgroups of data.

in a data step, you can store information from one iteration to the next, but you must calculate your own summaries.

 

Transportability

Most SQL queries can be moved to database servers with minor adjustments.

The data step must be run by SAS.

 

Efficiency

Proc SQL will perform on your behalf many optimisations that are not trivial.

A data step is a compiled program that can outperform any interpreted data manipulation script such as SQL, given enough effort.



 

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

Programming level

In proc SQL, you describe what you want and let the procedure figure out the way to do it.

In a data step, you describe what operations must be done, in detail, to get what you want.

 

Data structure

In proc SQL, tables are sets (unordered). Join operations are defined in terms of the cartesian product.

In a data step, datasets are sequences of records. Merge and update operations require prior sorting.

 

Summaries

In proc SQL, a limited group of summary functions can accumulate information about subgroups of data.

in a data step, you can store information from one iteration to the next, but you must calculate your own summaries.

 

Transportability

Most SQL queries can be moved to database servers with minor adjustments.

The data step must be run by SAS.

 

Efficiency

Proc SQL will perform on your behalf many optimisations that are not trivial.

A data step is a compiled program that can outperform any interpreted data manipulation script such as SQL, given enough effort.

PG
Patrick
Opal | Level 21

Suggest you do some own research and then post your detailed answer here for us to comment.

 

You could start with some Internet research. Already a simple Google search like "site:support.sas.com 9.4 sql vs data step" will return results.

 

 

SAS_inquisitive
Lapis Lazuli | Level 10

A simple google search  (proc sql and data step comparing) gives this paper.

 

http://www2.sas.com/proceedings/sugi29/269-29.pdf

 

Also, @PGStats offers this summary:

Programming level

In proc SQL, you describe what you want and let the procedure figure out the way to do it.

In a data step, you describe what operations must be done, in detail, to get what you want.

 

Data structure

In proc SQL, tables are sets (unordered). Join operations are defined in terms of the cartesian product.

In a data step, datasets are sequences of records. Merge and update operations require prior sorting.

 

Summaries

In proc SQL, a limited group of summary functions can accumulate information about subgroups of data.

in a data step, you can store information from one iteration to the next, but you must calculate your own summaries.

 

Transportability

Most SQL queries can be moved to database servers with minor adjustments.

The data step must be run by SAS.

 

Efficiency

Proc SQL will perform on your behalf many optimisations that are not trivial.

A data step is a compiled program that can outperform any interpreted data manipulation script such as SQL, given enough effort.



 

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
  • 3 replies
  • 4646 views
  • 5 likes
  • 4 in conversation