<?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: Require help with a Macro and to remove hard coding ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Require-help-with-a-Macro-and-to-remove-hard-coding/m-p/132720#M27025</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you have done at least part of the first two steps: 1) have working code and 2) Identify the parts that need to change.&lt;/P&gt;&lt;P&gt;For this you probably want to use named parameters to make the code easier to read. For things like your data sets this is common: (this is stub code just to show likely use)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro dummy (lib= , processyear= );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data newdata;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &lt;STRONG&gt;&amp;amp;lib..year&amp;amp;processyear._datasetname&lt;/STRONG&gt;;&amp;nbsp; /* this follows your example, note the . to connect the pieces of library and dataset name, any way &amp;amp;processyear has the value you plug into the name as needed*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;If the library doesnt change often you can assign a default in the macro definition but if it NEVER changes you could leave it hardcoded and not pass as parameter&lt;/P&gt;&lt;P&gt;%macro dummy(lib=mylib, processyear=);&lt;/P&gt;&lt;P&gt;The Nominee variables can be handled in a similar fashion&lt;/P&gt;&lt;P&gt;%macro dummy(lib=mylib, processyear=, AmNom=, MexNom=,LatAmNom=, AfNom=);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... This assues Nominee is a character variable and you are passing names, if numeric then the quotes aren't needed. The quotes below do need to be the &lt;STRONG&gt;double quote&lt;/STRONG&gt; to resolve properly&lt;/P&gt;&lt;P&gt;if A=american then nominee= "&amp;amp;AmNom";&lt;/P&gt;&lt;P&gt;else if A=mexican then nominee= "&amp;amp;MexNom";&lt;/P&gt;&lt;P&gt;else if A=LatinAmerican then nominee= "&amp;amp;LatAmNom";&lt;/P&gt;&lt;P&gt;/*continue the pattern*/&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 May 2013 20:09:19 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2013-05-08T20:09:19Z</dc:date>
    <item>
      <title>Require help with a Macro and to remove hard coding ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Require-help-with-a-Macro-and-to-remove-hard-coding/m-p/132719#M27024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI SAS Professionals,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My SAS code process has been written to import data from the database tables and I guess to create a few reports. I am in need of a macro to be able to reuse the same in production year after year. I am in need of help to parameterise in certain places in the codes with a macro and remove hard coding as the values are subject to change next year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Right now,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1. I have the dataset names like this: libref.year2013_datasetname and likewise it so occurs that all the datasets my process creates will also have dataset names such as libref.year2013_datasetname1............year2013_datasetnameN, which would be deemed wrong and wont work when data changes in the database next year as it would be year2014 next year.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2. I also noticed there are some hard coding in the script like:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if A= american then nominee= xxxx;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;else if A=mexican then nominee=yyyy;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;else if A=latin american the nominee=zzzz;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;else if A=african then nominee=gggg;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;So again the issue here is that the values are subject to change year after year in the database, therefore the above hard code needs to be changed in order to make it useful over and over again without touching it.So, when i look through it, i find there are many such instances.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm afraid I'm not a SAS guy and i'm basically covering for someone who has gone on leave and the situation got so desperate. Sorry for the bother.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 18:44:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Require-help-with-a-Macro-and-to-remove-hard-coding/m-p/132719#M27024</guid>
      <dc:creator>Allaluiah</dc:creator>
      <dc:date>2013-05-08T18:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Require help with a Macro and to remove hard coding ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Require-help-with-a-Macro-and-to-remove-hard-coding/m-p/132720#M27025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you have done at least part of the first two steps: 1) have working code and 2) Identify the parts that need to change.&lt;/P&gt;&lt;P&gt;For this you probably want to use named parameters to make the code easier to read. For things like your data sets this is common: (this is stub code just to show likely use)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro dummy (lib= , processyear= );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data newdata;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &lt;STRONG&gt;&amp;amp;lib..year&amp;amp;processyear._datasetname&lt;/STRONG&gt;;&amp;nbsp; /* this follows your example, note the . to connect the pieces of library and dataset name, any way &amp;amp;processyear has the value you plug into the name as needed*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;If the library doesnt change often you can assign a default in the macro definition but if it NEVER changes you could leave it hardcoded and not pass as parameter&lt;/P&gt;&lt;P&gt;%macro dummy(lib=mylib, processyear=);&lt;/P&gt;&lt;P&gt;The Nominee variables can be handled in a similar fashion&lt;/P&gt;&lt;P&gt;%macro dummy(lib=mylib, processyear=, AmNom=, MexNom=,LatAmNom=, AfNom=);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... This assues Nominee is a character variable and you are passing names, if numeric then the quotes aren't needed. The quotes below do need to be the &lt;STRONG&gt;double quote&lt;/STRONG&gt; to resolve properly&lt;/P&gt;&lt;P&gt;if A=american then nominee= "&amp;amp;AmNom";&lt;/P&gt;&lt;P&gt;else if A=mexican then nominee= "&amp;amp;MexNom";&lt;/P&gt;&lt;P&gt;else if A=LatinAmerican then nominee= "&amp;amp;LatAmNom";&lt;/P&gt;&lt;P&gt;/*continue the pattern*/&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 20:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Require-help-with-a-Macro-and-to-remove-hard-coding/m-p/132720#M27025</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-05-08T20:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Require help with a Macro and to remove hard coding ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Require-help-with-a-Macro-and-to-remove-hard-coding/m-p/132721#M27026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sir,&lt;/P&gt;&lt;P&gt;Thank you for the very nice guidance particularly for your valuable time. I did comprehend a fair bit, however i just thought of mentioning how the hard code looks like so that the practical solution can make understanding easier for a SAS beginner.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;Proc sort data=libref.year2013_dataset1 out=libref.dataset1_sorted&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;By variable1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;Proc sort data=libref.year2013_dataset2 out=libref.dataset2_sorted;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;By variable1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;Data libref.dataset3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif';"&gt;Merge &lt;/SPAN&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif';"&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif';"&gt;libref.dataset1_sorted&lt;/SPAN&gt; (in=a) &lt;/SPAN&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif';"&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif';"&gt;libref.dataset2_sorted&lt;/SPAN&gt;(in=b);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;By variable1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;If a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif';"&gt;Proc sort data=&lt;/SPAN&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif';"&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif';"&gt;libref.dataset3&lt;/SPAN&gt; out=&lt;/SPAN&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif';"&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif';"&gt;libref.dataset3&lt;/SPAN&gt;_sorted;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;By variable2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;Data libref.dataset4 &lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif';"&gt;Set libref.&lt;/SPAN&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif';"&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif';"&gt;dataset3&lt;/SPAN&gt;_sorted;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;var6= ‘valu.xx’;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;var7=var6;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;var8= var6' || var9;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;SELECT (country);/*variable named country in incoming dataset*/&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;WHEN (‘usa’)&amp;nbsp; ID = ‘usa.american’;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;WHEN (‘australian’) ID= ‘aus.ozzy’;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;When (‘england’) ID=’uk.eng’;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;When (‘canadian’) ID=’ca. maple’;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;When (‘mexico’) SK_ID=’mx.hispanic’;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;continues till all wriiten;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;Otherwise;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman','serif'; font-size: 12pt;"&gt;End;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 May 2013 18:02:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Require-help-with-a-Macro-and-to-remove-hard-coding/m-p/132721#M27026</guid>
      <dc:creator>Allaluiah</dc:creator>
      <dc:date>2013-05-09T18:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Require help with a Macro and to remove hard coding ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Require-help-with-a-Macro-and-to-remove-hard-coding/m-p/132722#M27027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Generally the bit I posted before applies directly. The difference is replacing the hardcoded bits with the macro parameters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;Proc sort data=libref.year2013_dataset1 out=libref.dataset1_sorted&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;By variable1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;Proc sort data=libref.year2013_dataset2 out=libref.dataset2_sorted;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;By variable1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;Data libref.dataset3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif';"&gt;Merge &lt;/SPAN&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif';"&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif';"&gt;libref.dataset1_sorted&lt;/SPAN&gt; (in=a) &lt;/SPAN&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif';"&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif';"&gt;libref.dataset2_sorted&lt;/SPAN&gt;(in=b);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;By variable1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;If a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif';"&gt;Proc sort data=&lt;/SPAN&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif';"&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif';"&gt;libref.dataset3&lt;/SPAN&gt; out=&lt;/SPAN&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif';"&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif';"&gt;libref.dataset3&lt;/SPAN&gt;_sorted;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;By variable2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;Could be replaced by:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;Proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create table libref.dataset3_sorted as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select a.*,b.*&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from libref.year2013_dataset1 as a left join libref.year2013_dataset2 as b on&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a.variable1=b.variable1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; order by b.variable2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;For a simple macro test you can create macro variables without a macro using let.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;%let procesyear=2013;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;Proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create table libref.dataset3_sorted as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select a.*,b.*&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from libref.year&amp;amp;processyear._dataset1 as a left join libref.year&amp;amp;processyear._dataset2 as b on&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a.variable1=b.variable1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; order by b.variable2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-IN" style="font-family: 'Times New Roman', 'serif'; font-size: 12pt;"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 May 2013 20:14:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Require-help-with-a-Macro-and-to-remove-hard-coding/m-p/132722#M27027</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-05-09T20:14:11Z</dc:date>
    </item>
  </channel>
</rss>

