<?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: Substituting a letter based on a macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Substituting-a-letter-based-on-a-macro-variable/m-p/697219#M213058</link>
    <description>&lt;P&gt;Macro variables do not resolve inside single quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;%macro get_State(st);
    data xxx; set yyy;
   if State = "" then State = "&amp;amp;st";
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a reliable value for ZIPcode you might use the ZIPSTATE function and skip this whole macro.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;
data xxx; set yyy;
   if State = "" then State = Zipstate(zipcode);
run;&lt;/LI-CODE&gt;
&lt;P&gt;This would correct all the missing if you have a zipcode value. Just a thought. Otherwise you may have some other issues if you need to change more than one state value.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Nov 2020 18:06:22 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-11-06T18:06:22Z</dc:date>
    <item>
      <title>Substituting a letter based on a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substituting-a-letter-based-on-a-macro-variable/m-p/697218#M213057</link>
      <description>&lt;P&gt;&amp;nbsp;I want to insert the two-character state abbreviation for a missing value. The state can change based on the data set I'm using.&amp;nbsp; If I try pass through a macro variable, I get a value of '&amp;amp;' rather than 'WI'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro get_State(st);
    data xxx; set yyy;
   if State = "" then State = '&amp;amp;st';
run;

%get_State(WI)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there any way I can get the macro variable st to be evaluated as a character string?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2020 17:58:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substituting-a-letter-based-on-a-macro-variable/m-p/697218#M213057</guid>
      <dc:creator>DocMartin</dc:creator>
      <dc:date>2020-11-06T17:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Substituting a letter based on a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substituting-a-letter-based-on-a-macro-variable/m-p/697219#M213058</link>
      <description>&lt;P&gt;Macro variables do not resolve inside single quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;%macro get_State(st);
    data xxx; set yyy;
   if State = "" then State = "&amp;amp;st";
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a reliable value for ZIPcode you might use the ZIPSTATE function and skip this whole macro.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;
data xxx; set yyy;
   if State = "" then State = Zipstate(zipcode);
run;&lt;/LI-CODE&gt;
&lt;P&gt;This would correct all the missing if you have a zipcode value. Just a thought. Otherwise you may have some other issues if you need to change more than one state value.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2020 18:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substituting-a-letter-based-on-a-macro-variable/m-p/697219#M213058</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-06T18:06:22Z</dc:date>
    </item>
  </channel>
</rss>

