<?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: Pass dataset variable value to a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390685#M277644</link>
    <description>&lt;P&gt;Reeza,&lt;/P&gt;&lt;P&gt;As you can tell, I am a complete neophyte and am&amp;nbsp;converting code fragments from the SAS documentation.&amp;nbsp; I thought of the FORMAT function first, but have not found any examples where it was used to convert a character value&amp;nbsp;to a numeric value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RXM&lt;/P&gt;</description>
    <pubDate>Thu, 24 Aug 2017 16:26:43 GMT</pubDate>
    <dc:creator>RXM</dc:creator>
    <dc:date>2017-08-24T16:26:43Z</dc:date>
    <item>
      <title>Pass dataset variable value to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390671#M277640</link>
      <description>&lt;P&gt;I have a simple macro that converts a letter value to a numeric value:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;%macro&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; grade(color);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%global&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; colorgrade;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; incolor=&amp;amp;color;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;select(&amp;amp;incolor);&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;when (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'L'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) colorgrade=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;8&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;when (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'B'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) colorgrade=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;when (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'G'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) colorgrade=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;when (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'Y'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) colorgrade=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;when (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'R'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) colorgrade=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;otherwise colorgrade=-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;%mend&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; grade;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;My problem is passing the value of&amp;nbsp;the dataset variable to the macro. Instead of the value of the variable ('G'), it passes the variable name (color).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 16:10:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390671#M277640</guid>
      <dc:creator>RXM</dc:creator>
      <dc:date>2017-08-24T16:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Pass dataset variable value to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390677#M277641</link>
      <description>&lt;P&gt;Please show how you're using this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An alternative - a better one IMO - is to use a FORMAT.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 16:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390677#M277641</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-24T16:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Pass dataset variable value to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390680#M277642</link>
      <description>&lt;P&gt;From what you have shown so far, the macro actually needs the variable name.&amp;nbsp; It would be wrong to pass the variable value.&amp;nbsp; Certainly this statement would be incorrect syntax in a DATA step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select ('G');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondarily, what is the purpose of the %GLOBAL statement?&amp;nbsp; There is nothing about this code that assigns a value to a macro variable named COLORGRADE.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 16:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390680#M277642</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-24T16:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Pass dataset variable value to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390682#M277643</link>
      <description>&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%global&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;colorgrade; &amp;lt;- what's this for, it's not used in the code you've shown.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;incolor=&amp;amp;color; &amp;lt;- this isn't needed, renaming the macro variable?&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 16:22:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390682#M277643</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-24T16:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Pass dataset variable value to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390685#M277644</link>
      <description>&lt;P&gt;Reeza,&lt;/P&gt;&lt;P&gt;As you can tell, I am a complete neophyte and am&amp;nbsp;converting code fragments from the SAS documentation.&amp;nbsp; I thought of the FORMAT function first, but have not found any examples where it was used to convert a character value&amp;nbsp;to a numeric value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RXM&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 16:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390685#M277644</guid>
      <dc:creator>RXM</dc:creator>
      <dc:date>2017-08-24T16:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: Pass dataset variable value to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390687#M277645</link>
      <description>&lt;P&gt;Search Lexjansen.com for any topics, you'll find papers and full code examples:&lt;/P&gt;
&lt;P&gt;Page 4 of this paper has an example.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi27/p056-27.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi27/p056-27.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 16:32:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390687#M277645</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-24T16:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Pass dataset variable value to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390689#M277646</link>
      <description>&lt;P&gt;Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much!&amp;nbsp;&amp;nbsp;&amp;nbsp; I knew there would be an elegant solution!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RXM&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 16:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390689#M277646</guid>
      <dc:creator>RXM</dc:creator>
      <dc:date>2017-08-24T16:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Pass dataset variable value to a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390764#M277647</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/156799"&gt;@RXM&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Reeza,&lt;/P&gt;
&lt;P&gt;As you can tell, I am a complete neophyte and am&amp;nbsp;converting code fragments from the SAS documentation.&amp;nbsp; I thought of the FORMAT function first, but have not found any examples where it was used to convert a character value&amp;nbsp;to a numeric value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RXM&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Formats are for displaying values, so they always generate text. &amp;nbsp;But an INFORMAT can be used to generate numeric values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
  invalue colorgrade
    'L'=8
    'B'=6
    'G'=4
    'Y'=2
    'R'=0
    other=-2
  ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Aug 2017 21:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-dataset-variable-value-to-a-macro/m-p/390764#M277647</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-24T21:09:17Z</dc:date>
    </item>
  </channel>
</rss>

