<?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 Dynamic way to handle multiple conditions with macro variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-to-handle-multiple-conditions-with-macro-variables/m-p/612612#M178800</link>
    <description />
    <pubDate>Thu, 19 Dec 2019 09:28:54 GMT</pubDate>
    <dc:creator>David_Billa</dc:creator>
    <dc:date>2019-12-19T09:28:54Z</dc:date>
    <item>
      <title>Dynamic way to handle multiple conditions with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-to-handle-multiple-conditions-with-macro-variables/m-p/612612#M178800</link>
      <description />
      <pubDate>Thu, 19 Dec 2019 09:28:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-to-handle-multiple-conditions-with-macro-variables/m-p/612612#M178800</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-12-19T09:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic way to handle multiple conditions with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-to-handle-multiple-conditions-with-macro-variables/m-p/612618#M178803</link>
      <description>&lt;P&gt;So ENT_CUR_VLU1 has commas in it. When %SCAN sees a comma, it thinks it has come to the end of the argument, then next argument is the values after the comma, and that doesn't make sense in this case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to mask the comma in your macro variable, as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%scan(%bquote(&amp;amp;ENT_CUR_VLU1.,1))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then %SCAN will think the comma is simply text instead of thinking it is the end of the argument.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the future, please paste the entire log of the SQL step (not just the error messages) into the window that appears when you click on the {i} icon. Just showing the error messages disconnected from the code (as you have done) makes it much harder to figure out where the problem has occurred.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 13:05:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-to-handle-multiple-conditions-with-macro-variables/m-p/612618#M178803</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-18T13:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic way to handle multiple conditions with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-to-handle-multiple-conditions-with-macro-variables/m-p/612619#M178804</link>
      <description>&lt;P&gt;You still suffer from extreme Macro-itis.&lt;/P&gt;
&lt;P&gt;Create a format from the data, and use a simple put statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lookup;
input (incode outcode) (:$9.);
fmtname = 'myfmt';
type = "C";
if _n_ = 1
then do;
  start = 'Other';
  label = '***';
  hlo = 'O';
  output;
end;
start = substr(incode,1,4);
label = substr(outcode,6);
hlo = '';
output;
keep fmtname type start label;
datalines;
1234_EUR 5432_PLN
5678_EUR 5432_PLN
8901_EUR 5432_PLN
;

proc format cntlin=lookup;
run;

data have;
input unit $ currency $;
datalines;
1234 XXX
5678 YYY
0000 GBP
;

proc sql;
create table want as
select
  unit,
  case
    when put(unit,$myfmt.) = '***'
    then currency
    else put(unit,$myfmt.)
  end as currency
from have;
quit;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;unit    currency

1234      PLN   
5678      PLN   
0000      GBP   
&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Dec 2019 11:55:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-to-handle-multiple-conditions-with-macro-variables/m-p/612619#M178804</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-18T11:55:03Z</dc:date>
    </item>
  </channel>
</rss>

