<?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 Resolving a Macro variable within Format within PROC DATA. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Resolving-a-Macro-variable-within-Format-within-PROC-DATA/m-p/239059#M55481</link>
    <description>&lt;P&gt;Dear everybody!&lt;/P&gt;&lt;P&gt;How can I refer to the dynamic name of the format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my situation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%Macro myMacro (myVar);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;PROC FORMAT CNTLOUT= fmtdataset;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;VALUE &amp;amp;myVar&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 = 'Label1'&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 = 'Label2'&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ;&lt;BR /&gt;&amp;nbsp; RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Data somedataset_formatted;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set somedataset;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; FORMAT &amp;amp;myVar &amp;amp;myVar. ; &amp;nbsp; /*&lt;SPAN&gt;I also tried FORMAT &amp;amp;myVar "&amp;amp;myVar."; – get a syntax error message */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; RUN;&lt;/P&gt;&lt;P&gt;%Mend myMacro&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I call %myMacro (variableName) I get no&amp;nbsp;errors. The file fmtdataset contains the appropriate format "variableName". However, in the dataset "somedataset" the variable variableName doesn't get formatted. If I replace the macro with values, i.e.,&amp;nbsp;&lt;/P&gt;&lt;P&gt;FORMAT variableName variableName. &amp;nbsp;it works just fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Julia&lt;/P&gt;</description>
    <pubDate>Sun, 13 Dec 2015 18:29:31 GMT</pubDate>
    <dc:creator>braverju</dc:creator>
    <dc:date>2015-12-13T18:29:31Z</dc:date>
    <item>
      <title>Resolving a Macro variable within Format within PROC DATA.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Resolving-a-Macro-variable-within-Format-within-PROC-DATA/m-p/239059#M55481</link>
      <description>&lt;P&gt;Dear everybody!&lt;/P&gt;&lt;P&gt;How can I refer to the dynamic name of the format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my situation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%Macro myMacro (myVar);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;PROC FORMAT CNTLOUT= fmtdataset;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;VALUE &amp;amp;myVar&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 = 'Label1'&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 = 'Label2'&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ;&lt;BR /&gt;&amp;nbsp; RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Data somedataset_formatted;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set somedataset;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; FORMAT &amp;amp;myVar &amp;amp;myVar. ; &amp;nbsp; /*&lt;SPAN&gt;I also tried FORMAT &amp;amp;myVar "&amp;amp;myVar."; – get a syntax error message */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; RUN;&lt;/P&gt;&lt;P&gt;%Mend myMacro&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I call %myMacro (variableName) I get no&amp;nbsp;errors. The file fmtdataset contains the appropriate format "variableName". However, in the dataset "somedataset" the variable variableName doesn't get formatted. If I replace the macro with values, i.e.,&amp;nbsp;&lt;/P&gt;&lt;P&gt;FORMAT variableName variableName. &amp;nbsp;it works just fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Julia&lt;/P&gt;</description>
      <pubDate>Sun, 13 Dec 2015 18:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Resolving-a-Macro-variable-within-Format-within-PROC-DATA/m-p/239059#M55481</guid>
      <dc:creator>braverju</dc:creator>
      <dc:date>2015-12-13T18:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving a Macro variable within Format within PROC DATA.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Resolving-a-Macro-variable-within-Format-within-PROC-DATA/m-p/239061#M55483</link>
      <description>I think you need an extra period at the end of the format name. Periods are used to indicate the end of a macro variable, so the first one gets used by the macro variable and the second is for the format.&lt;BR /&gt;&lt;BR /&gt;FORMAT &amp;amp;myVar &amp;amp;myVar.. ;</description>
      <pubDate>Sun, 13 Dec 2015 18:30:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Resolving-a-Macro-variable-within-Format-within-PROC-DATA/m-p/239061#M55483</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-13T18:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving a Macro variable within Format within PROC DATA.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Resolving-a-Macro-variable-within-Format-within-PROC-DATA/m-p/239062#M55484</link>
      <description>Hurray! It worked. Thank you very much!</description>
      <pubDate>Sun, 13 Dec 2015 18:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Resolving-a-Macro-variable-within-Format-within-PROC-DATA/m-p/239062#M55484</guid>
      <dc:creator>braverju</dc:creator>
      <dc:date>2015-12-13T18:33:37Z</dc:date>
    </item>
  </channel>
</rss>

