<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SAS Macros in datalines in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/SAS-Macros-in-datalines/m-p/506405#M1313</link>
    <description>&lt;P&gt;Macro&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;does not work&lt;/STRONG&gt;&lt;/U&gt; in datalines.&amp;nbsp; You would need to use the resolve() function for that.&amp;nbsp; However I highly recommend you review your code/process and avoid using macro as much at possible.&amp;nbsp; Most of that code is avoidable by dropping all the macro stuff and using Base Datastep.&amp;nbsp; This alone:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%macro applylogic;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%do i= 1 %to &amp;amp;lastrow;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;data &amp;amp;persontbla ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is resource heavy and verbose, all those datasets being created.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Oct 2018 12:07:40 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-10-22T12:07:40Z</dc:date>
    <item>
      <title>SAS Macros in datalines</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Macros-in-datalines/m-p/506397#M1311</link>
      <description>&lt;P&gt;I am using macro variable in datalines. I am getting error ERROR: &lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;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&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt;. 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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data employee;&lt;BR /&gt;length emailAddr $30. userid $30.;&lt;BR /&gt;input keyid$ name$ displayname$ emailAddr$ memkeyid$ userid$;&lt;BR /&gt;datalines;&lt;BR /&gt;P002 IBL11152 Atest1 email1@address P002 IBL\IBL11152&lt;BR /&gt;P003 IBL11153 Atest2 email2@address P003 IBL\IBL11153&lt;BR /&gt;P004 IBL11154 Atest3 email3@address P004 IBL\IBL11154&lt;BR /&gt;P005 IBL11155 Atest4 email4@address P005 IBL\IBL11155&lt;BR /&gt;P006 IBL11156 Atest5 email5@address P006 IBL\IBL11156&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%macro loopmacro;&lt;BR /&gt;%global keyidm namen displaynamem emailAddrm memkeyidm useridm lastrow;&lt;BR /&gt;data _null_;&lt;BR /&gt;set employee end=eof;&lt;BR /&gt;call symput('keyidm'||left(_n_),keyid);&lt;BR /&gt;call symput('namen'||left(_n_),name);&lt;BR /&gt;call symput('displaynamem'||left(_n_),displayname);&lt;BR /&gt;call symput('emailAddrm'||left(_n_),emailAddr);&lt;BR /&gt;call symput('memkeyidm'||left(_n_),memkeyid);&lt;BR /&gt;call symput('useridm'||left(_n_),userid);&lt;BR /&gt;if eof then call symput ('lastrow', left(_n_));&lt;BR /&gt;run;&lt;BR /&gt;%put &amp;amp;lastrow;&lt;BR /&gt;%mend;&lt;BR /&gt;%loopmacro;&lt;BR /&gt;%put &amp;amp;lastrow;&lt;/P&gt;&lt;P&gt;/* The meaning of canonical, if you are in doubt &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;"Conforming to orthodox or well-established rules or patterns, as of procedure."&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;options symbolgen mprint mlogic;&lt;BR /&gt;/*--------------------------------------------------------&lt;BR /&gt;* Example based on MDUIMPC and MDUIMPL macros to import&lt;BR /&gt;* user info to the SAS Metadata Server.&lt;BR /&gt;*--------------------------------------------------------- */&lt;/P&gt;&lt;P&gt;/*--------------------------------------------------------&lt;BR /&gt;* FILL OUT INFO FOR METASERVER and METAUSER!!!!!!!!!&lt;BR /&gt;*----------------------------------------------------------*/&lt;BR /&gt;options metaserver= "*********" /*Your server Hostname */&lt;BR /&gt;metaport=8561&lt;BR /&gt;metauser="I&lt;SPAN&gt;*********&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;"&lt;BR /&gt;metapass="&lt;SPAN&gt;*********&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;"&lt;BR /&gt;metaprotocol=bridge&lt;BR /&gt;metarepository=Foundation;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt;%MDUIMPC macro is used to define "canonical" tables and the data step is&lt;BR /&gt;used to extract data from external sources and append them to the tables.&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;%mduimpc();&lt;/P&gt;&lt;P&gt;/* Create person table */&lt;BR /&gt;%macro applylogic;&lt;BR /&gt;%do i= 1 %to &amp;amp;lastrow;&lt;BR /&gt;data &amp;amp;persontbla ;&lt;BR /&gt;%definepersoncols;&lt;BR /&gt;infile datalines delimiter=',' missover;&lt;BR /&gt;input keyid name description title displayname;&lt;BR /&gt;&lt;BR /&gt;datalines;&lt;BR /&gt;&amp;amp;&amp;amp;keyidm&amp;amp;i.,&amp;amp;&amp;amp;namen&amp;amp;i., ,CCBG,&amp;amp;&amp;amp;displaynamem&amp;amp;i.&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%applylogic;&lt;/P&gt;&lt;P&gt;/*filename testxml 'filename.xml' lrecl=1024;*/&lt;BR /&gt;/*%mduimpl(outrequest=testxml);*/&lt;/P&gt;&lt;P&gt;%mduimpl();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 11:43:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Macros-in-datalines/m-p/506397#M1311</guid>
      <dc:creator>sameer112217</dc:creator>
      <dc:date>2018-10-22T11:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macros in datalines</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Macros-in-datalines/m-p/506405#M1313</link>
      <description>&lt;P&gt;Macro&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;does not work&lt;/STRONG&gt;&lt;/U&gt; in datalines.&amp;nbsp; You would need to use the resolve() function for that.&amp;nbsp; However I highly recommend you review your code/process and avoid using macro as much at possible.&amp;nbsp; Most of that code is avoidable by dropping all the macro stuff and using Base Datastep.&amp;nbsp; This alone:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%macro applylogic;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%do i= 1 %to &amp;amp;lastrow;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;data &amp;amp;persontbla ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is resource heavy and verbose, all those datasets being created.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 12:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Macros-in-datalines/m-p/506405#M1313</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-22T12:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macros in datalines</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Macros-in-datalines/m-p/506418#M1315</link>
      <description>&lt;P&gt;What you're trying to do here is a nice example for how &lt;STRONG&gt;NOT&lt;/STRONG&gt; to do it. You try to abuse the macro preprocessor for handling data, which results in convoluted and hard to create/maintain/understand code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to create code based on datasets, don't create lots of macro pseudo-arrays, use call execute() instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the %mdu.... macros are pefectly good for handling multiple users in one step, so the creation of multiple datasets with one person each is nonsense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A nice example for bulk import of users is found in SASHOME/SASFoundation/9.4/samples/base/importpw.sas. I use a slightly adapted version of this program for the automated synchronization of my operating system userbase with SAS metadata.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 12:48:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Macros-in-datalines/m-p/506418#M1315</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-22T12:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macros in datalines</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Macros-in-datalines/m-p/506423#M1319</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason why macro facility does not accept &lt;FONT face="courier new,courier"&gt;datalines&lt;/FONT&gt; statements is explained in:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/kb/43/902.html" target="_blank"&gt;http://support.sas.com/kb/43/902.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which is linked to in the below, which describes the use of the &lt;FONT face="courier new,courier"&gt;resolve()&lt;/FONT&gt; function mentioned by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/kb/43/295.html" target="_blank"&gt;http://support.sas.com/kb/43/295.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 13:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Macros-in-datalines/m-p/506423#M1319</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2018-10-22T13:01:43Z</dc:date>
    </item>
  </channel>
</rss>

