04-03-2017 04:25 AM - edited 04-03-2017 04:43 AM
filename code temp; data C; set A nobs=nobs ; file code ; do part=0 to int(nobs/1000); put '%macro1(inputtable=A, outputtable = B_P, size=1000,part=' part')' ; end; stop; run; %include code / source2 ;
I have a table A which create several B tables named B_P0, B_P2,...,B_P(n-1)
I would like to create in the same datastep the table C as an union of all B_P tables, and then delete B_P tables.
How can I do this?
04-03-2017 06:51 AM - edited 04-03-2017 06:55 AM
I tried to do something like that:
%macro union(partnumber); data C; set B_P0; run; %do part=1 %to &partnumber; PROC APPEND BASE= C DATA= B_P.part; RUN; %end; %mend; filename code temp; data _null_; set A nobs=nobs ; file code ; nb = int(nobs/1000); do part=0 to int(nobs/1000); put '%macro1(inputtable=A, outputtable = B_P, size=1000,part=' part')' ; end; stop; put '%union(partnumber = ' nb')' ; run; %include code / source2 ;
But apparantly it is not working.
It is running for a very long time without answers.
04-03-2017 10:32 AM
It is very hard to tell what is wrong with your code when we do not know what the %MACRO1 macro is supposed to do.
When you say it is running for a very long time without answers. does that mean that you never see the "source2" code in the log? In that case it seems to mean that the first call of %MACRO1 is somehow stuck and just hangs.
What happens if you open the generated program in an editor and submit line by line? That is the great advantage of generating a file instead of using CALL EXECUTE or such: when developing/testing, you can take a good, long look at the generated code before submitting it, and you can submit it one step at a time and check the output before you proceed.
BTW, you put the
put '%union(partnumber = ' nb')' ;
after the "stop;" statement in your datastep, meaning that it does not get written to the code file.