nested data step

Posts: 25

nested data step

How to run nested data step in sas or

how to call a data step in another data step ?

Super Contributor
Posts: 339

Re: nested data step

Posted in reply to gupta_shubham


A data step is boundary is met when another data statement is encountered and so data steps cannot be nested.



Super Contributor
Posts: 339

Re: nested data step

It is actually arguably possible to nest datastep with SAS9.2 but it requires tedious efforts.

Using PROC FCMP, you can create a routine that you can call in your outer data step.

With the RUN_MACRO and dosubl tools in proc FCMP, you can force SAS to execute the inner data step that you would preemptively have wrapped in a macro. The RUN_MACRO allows you to execute the macro right away rather than piling it up to be executed at the end of your current data step like with call execute.

Typically, there would be other better ways around so if you are not an experienced SAS user, you would probably be better detailing the intention behind your code as there are very likely ways around that. However, if you are in for a nice self-learning experience, look into



Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation