10-18-2011 10:12 PM
Hi ... there maybe an easier way to do this, but you can turn the code you want to include into a macro variable ...
* some SQL statements in an external file;
put 'from sashelp.class';
put 'where sex eq "M"';
* create a macro variable from the statements in the external file;
length stuff $1000;
infile 'z:\stuff.txt' end=done;
do until (done);
stuff = catx(' ',stuff,_infile_);
* "include" the statements using the macro variable;
create table males as
10-18-2011 10:42 PM
First of all. %include is not a part of Macro facility. So you can put the code into SQL.
But you can make a macro to include these code and use macro to put the code into SQL.
10-19-2011 08:34 AM
As far as I know there is no particular limitation on using %INCLUDE in PROC SQL. The rule is that %INCLUDE has to appear at a statement boundary. Of course there are not a lot of statement boundaries in SQL code.
I’d like to be able to include blocs of code within PROC SQL using %include statements. But doing so generates error messages. Is there some option or technique to accomplish this?
10-19-2011 10:43 AM
Hi ... correct (as expected !) ...
put 'create table males as select *' /
'from sashelp.class' /
'where sex eq "M";';
26 proc sql;
27 %include 'z:\stuff.txt';
NOTE: Table WORK.MALES created, with 10 rows and 5 columns.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.96 seconds
cpu time 0.14 seconds