I am using macro variable in datalines. I am getting error ERROR: The macro APPLYLOGIC generated CARDS (data lines) for the DATA step, which could cause incorrect results. The DATA step and the macro will stop executing. Please suggest me code where I can invoke macro variable in the datalines. The below code is for adding sample username to metadata in bulk. I can use the set statement and external file but for learning purpose I want to know function to use macro in datalines.
data employee;
length emailAddr $30. userid $30.;
input keyid$ name$ displayname$ emailAddr$ memkeyid$ userid$;
datalines;
P002 IBL11152 Atest1 email1@address P002 IBL\IBL11152
P003 IBL11153 Atest2 email2@address P003 IBL\IBL11153
P004 IBL11154 Atest3 email3@address P004 IBL\IBL11154
P005 IBL11155 Atest4 email4@address P005 IBL\IBL11155
P006 IBL11156 Atest5 email5@address P006 IBL\IBL11156
;
run;
%macro loopmacro;
%global keyidm namen displaynamem emailAddrm memkeyidm useridm lastrow;
data _null_;
set employee end=eof;
call symput('keyidm'||left(_n_),keyid);
call symput('namen'||left(_n_),name);
call symput('displaynamem'||left(_n_),displayname);
call symput('emailAddrm'||left(_n_),emailAddr);
call symput('memkeyidm'||left(_n_),memkeyid);
call symput('useridm'||left(_n_),userid);
if eof then call symput ('lastrow', left(_n_));
run;
%put &lastrow;
%mend;
%loopmacro;
%put &lastrow;
/* The meaning of canonical, if you are in doubt 🙂
"Conforming to orthodox or well-established rules or patterns, as of procedure."
*/
options symbolgen mprint mlogic;
/*--------------------------------------------------------
* Example based on MDUIMPC and MDUIMPL macros to import
* user info to the SAS Metadata Server.
*--------------------------------------------------------- */
/*--------------------------------------------------------
* FILL OUT INFO FOR METASERVER and METAUSER!!!!!!!!!
*----------------------------------------------------------*/
options metaserver= "*********" /*Your server Hostname */
metaport=8561
metauser="I*********""
metapass="*********""
metaprotocol=bridge
metarepository=Foundation;
/*
%MDUIMPC macro is used to define "canonical" tables and the data step is
used to extract data from external sources and append them to the tables.
*/
%mduimpc();
/* Create person table */
%macro applylogic;
%do i= 1 %to &lastrow;
data &persontbla ;
%definepersoncols;
infile datalines delimiter=',' missover;
input keyid name description title displayname;
datalines;
&&keyidm&i.,&&namen&i., ,CCBG,&&displaynamem&i.
;
run;
%end;
%mend;
%applylogic;
/*filename testxml 'filename.xml' lrecl=1024;*/
/*%mduimpl(outrequest=testxml);*/
%mduimpl();