@Rain_28 wrote:
Yes, the code worked by writing the whole datastep in call execute...this is the first time I wrote complicated call execute within multiple loops in a macro. It took me couple of days but got it....Thank you so much! Really appreciate your help.
Good. The point of making a macro that the code generation can call is to simplify the data driven code generation step. Rather than generating the full data step code you just need to pass the parts that vary to a macro. Then you can debug the process of converting the parts that vary into proper code independent from the data driven step.
You can also skip CALL EXECUTE() and just use the data step to write the code directly to a file. This will normally be a lot easier to debug. Plus you can use the power of the PUT statement and not have to fight with text manipulation function calls. You can examine the file and make sure it will work. Copy and paste part of the code back into the editor window and run it to see if it is going to work. etc.
filename code temp;
data _null_;
set metadata ;
file code;
put 'data new;'
/ ' set ' dsname ';'
/ 'run;'
;
run;
%include code / source2;
... View more