LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 5 Mar 2008 03:50:24 -0800
Reply-To:   karma <dorjetarap@GOOGLEMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   karma <dorjetarap@GOOGLEMAIL.COM>
Organization:   http://groups.google.com
Subject:   using datalines(cards) within a macro definition
Comments:   To: sas-l@uga.edu
Content-Type:   text/plain; charset=ISO-8859-1

I want to find a way to create a dataset within a macro definition.

I have tried the following:

%macro test; data categories; infile datalines dlm=',' dsd; length category $55; input category $ _group _order; datalines; "Genotype consent",1,1 " Obtained",1,2 " Not obtained",1,3 "Genotype sample status",2,4 " Collected and evaluated",2,5 " Collected but not evaluated ~(due to withdrawn consent)",2,6 " Collected but not evaluable",2,7 " Not collected",2,8 ; run; %mend;

%test;

This generates the following error:

ERROR: The macro TEST generated CARDS (data lines) for the DATA step, which could cause incorrect results. The DATA step and the macro will stop executing.

Looking at the sas support I found the following information on this:

"A macro definition cannot contain a CARDS statement, a DATALINES statement, a PARMCARDS statement, or data lines. Use an INFILE statement instead."

Unfortunately our systems require code to be wrapped in a macro for execution, and I would like the code to be portable. Does anyone know of a way around this??

Thanks in advance


Back to: Top of message | Previous page | Main SAS-L page