<?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: how to use the Marco to repeat codes in three datasets having the same variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-the-Marco-to-repeat-codes-in-three-datasets-having/m-p/530813#M145180</link>
    <description>&lt;P&gt;Ok, thanks a lot for the suggestions. we will do.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Jan 2019 22:27:25 GMT</pubDate>
    <dc:creator>rainemationg03</dc:creator>
    <dc:date>2019-01-28T22:27:25Z</dc:date>
    <item>
      <title>how to use the Marco to repeat codes in three datasets having the same variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-the-Marco-to-repeat-codes-in-three-datasets-having/m-p/529978#M144895</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if anyone can help me on how to code using macro.I am very new to this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have three survey data sets, collected at baseline, follow-up1 and follow up 2. These datasets have similar information collected. In order not to repeat the same codes in processing the data from one dataset to another, I am planning to use macro codes.&amp;nbsp; I am using SAS 9.4 for windows system.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let MainPath= C:\MGP;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*Exctracting datasets from Access database and Assigning Libnames;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*baseline*/&lt;BR /&gt;libname mgpbl "&amp;amp;MainPath\Data\Source Data\BL\UB2016BL.mdb";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*FU1*/&lt;BR /&gt;libname mgpf1 "&amp;amp;MainPath\Data\Source Data\FU1\UB2016FU1.mdb";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*FU2*/&lt;BR /&gt;libname mgpf2 "&amp;amp;MainPath\Data\Source Data\FU2\UB016FU2.mdb";&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*libname SAS data*/&lt;/P&gt;&lt;P&gt;libname mgp "&amp;amp;MainPath\Data\SASData";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm already stucked in the following because I am getting errors, I don't know how to proceed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro St (TimeIn = ,&amp;nbsp; mgpbl = mgpbl);&lt;/P&gt;&lt;P&gt;data mgp.&amp;amp;TimeIn.StResults&lt;BR /&gt;set &amp;amp;mgpbl..&amp;amp;TimeIn.StColl&amp;nbsp;&lt;BR /&gt;%if &amp;amp;TimeIn eq Baseline %then %do;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%mend&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope&amp;nbsp; you can shed some light.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 06:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-the-Marco-to-repeat-codes-in-three-datasets-having/m-p/529978#M144895</guid>
      <dc:creator>rainemationg03</dc:creator>
      <dc:date>2019-01-25T06:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to use the Marco to repeat codes in three datasets having the same variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-the-Marco-to-repeat-codes-in-three-datasets-having/m-p/529983#M144897</link>
      <description>&lt;P&gt;Do you have working code solving the issue for one dataset? If not: write that code, then identifying the things that have to be replaced by macro-code are more obvious.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the posted code, an %end-statement is required before %mend.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 07:55:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-the-Marco-to-repeat-codes-in-three-datasets-having/m-p/529983#M144897</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-01-25T07:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to use the Marco to repeat codes in three datasets having the same variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-the-Marco-to-repeat-codes-in-three-datasets-having/m-p/529995#M144898</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;I have three survey data sets, collected at baseline, follow-up1 and follow up 2. These datasets have similar information collected"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you have data that is the same, put it in one dataset, then your code only has to execute, and produce output once, rather than 3 times which is the way your aiming.&amp;nbsp; For instance:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;/*baseline*/
libname mgpbl "&amp;amp;MainPath\Data\Source Data\BL\UB2016BL.mdb";

/*FU1*/
libname mgpf1 "&amp;amp;MainPath\Data\Source Data\FU1\UB2016FU1.mdb";

/*FU2*/
libname mgpf2 "&amp;amp;MainPath\Data\Source Data\FU2\UB016FU2.mdb";

data total;
  length source $200;
  set mgpbl.&amp;lt;data&amp;gt;    
        mgpf1.&amp;lt;data&amp;gt;
        mgpf2.&amp;lt;data&amp;gt;
        indsname=tmp;
  source=tmp;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Note that I use &amp;lt;data&amp;gt; as I do not know what your sets are called.&amp;nbsp; What this will do is put all the data from the three tables one under the other, and have a variable name as the source.&amp;nbsp; Then you can process as one dataset.&amp;nbsp; If you need them horizontal, you could merge (join) them, or transpose from the one datasource.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Tip: Macro is never needed, use Base SAS all the time to get robust, resource friendly, easy to read code.&amp;nbsp; Only resort to macro where it adds something to the process, such as re-usability.&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2019 09:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-the-Marco-to-repeat-codes-in-three-datasets-having/m-p/529995#M144898</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-01-25T09:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to use the Marco to repeat codes in three datasets having the same variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-the-Marco-to-repeat-codes-in-three-datasets-having/m-p/530813#M145180</link>
      <description>&lt;P&gt;Ok, thanks a lot for the suggestions. we will do.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2019 22:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-the-Marco-to-repeat-codes-in-three-datasets-having/m-p/530813#M145180</guid>
      <dc:creator>rainemationg03</dc:creator>
      <dc:date>2019-01-28T22:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to use the Marco to repeat codes in three datasets having the same variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-the-Marco-to-repeat-codes-in-three-datasets-having/m-p/530814#M145181</link>
      <description>Thank you so much for your reply. We will try the codes that you have suggested.</description>
      <pubDate>Mon, 28 Jan 2019 22:32:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-the-Marco-to-repeat-codes-in-three-datasets-having/m-p/530814#M145181</guid>
      <dc:creator>rainemationg03</dc:creator>
      <dc:date>2019-01-28T22:32:02Z</dc:date>
    </item>
  </channel>
</rss>

