Date: Wed, 18 Mar 1998 12:33:56 -0500
Reply-To: WHITLOI1 <WHITLOI1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: WHITLOI1 <WHITLOI1@WESTAT.COM>
Subject: Re: CARDS INSIDE MACROS
Content-Type: text/plain; charset=US-ASCII
Subject: CARDS INSIDE MACROS
Summary: Use %INCLUDE.
Respondent: Ian Whitlock <whitloi1@westat.com>
Abdu Elnagheeb <abdu.elnagheeb@NATIONSBANK.COM> asks a classic
question - how to use a CARDS statement in a macro. The short answer
is that you can't and probably shouldn't want to. CARDS are for quick
and dirty work, macros are too much trouble if you aren't willing to
plan and take care.
However, one can include code with a CARDS statement because the
%INCLUDE is processed by the compiler not the macro facility. Just
becareful to include the ending semi-colon in the include file.
164 %macro q ;
165 data w ;
166 input x y z ;
167 list ;
168 %inc 'c:\my documents\junk\q.sas' / source2 ;
169 run ;
170 %mend q ;
171
172 %q
NOTE: %INCLUDE (level 1) file c:\my documents\junk\q.sas is file
c:\my documents\junk\q.sas.
173 +cards ;
RULE:----+----1----+----2----+----3----+----4----+----5----+----6
----+----7----+----8----+----9--
174 1 2 3
175 4 5 6
NOTE: The data set WORK.W has 2 observations and 3 variables.
NOTE: The DATA statement used 0.48 seconds.
176 +;
NOTE: %INCLUDE (level 1) ending.
Ian Whitlock