<?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 how to ignore macro variable error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-ignore-macro-variable-error/m-p/615937#M180225</link>
    <description>&lt;P&gt;data main ;&lt;BR /&gt;input id score ;&lt;BR /&gt;cards ;&lt;BR /&gt;101 200&lt;BR /&gt;102 355&lt;BR /&gt;;&lt;BR /&gt;proc sql ;&lt;BR /&gt;select score into:rate1 from main where id=101 ;&lt;BR /&gt;select score into:rate2 from main where id=102 ;&lt;BR /&gt;select score into:rate3 from main where id=103 ;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;rate1 &amp;amp;rate2 ;&lt;/P&gt;
&lt;P&gt;data want ;&lt;BR /&gt;set main ;&lt;BR /&gt;var1=symgetn("rate1")*1 ;&lt;BR /&gt;var2=symgetn("rate2")*1.5 ;&lt;BR /&gt;var3=symgetn("rate3")*2 ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one dataset like main in that only two id's there in future may be 3 id's there so I created 3 macro variables next I wrote&lt;/P&gt;
&lt;P&gt;One calculation I got var1 ,var2 results however for var3 I am getting error log window how to ignore that error.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Jan 2020 14:31:31 GMT</pubDate>
    <dc:creator>thanikondharish</dc:creator>
    <dc:date>2020-01-08T14:31:31Z</dc:date>
    <item>
      <title>how to ignore macro variable error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-ignore-macro-variable-error/m-p/615937#M180225</link>
      <description>&lt;P&gt;data main ;&lt;BR /&gt;input id score ;&lt;BR /&gt;cards ;&lt;BR /&gt;101 200&lt;BR /&gt;102 355&lt;BR /&gt;;&lt;BR /&gt;proc sql ;&lt;BR /&gt;select score into:rate1 from main where id=101 ;&lt;BR /&gt;select score into:rate2 from main where id=102 ;&lt;BR /&gt;select score into:rate3 from main where id=103 ;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;rate1 &amp;amp;rate2 ;&lt;/P&gt;
&lt;P&gt;data want ;&lt;BR /&gt;set main ;&lt;BR /&gt;var1=symgetn("rate1")*1 ;&lt;BR /&gt;var2=symgetn("rate2")*1.5 ;&lt;BR /&gt;var3=symgetn("rate3")*2 ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one dataset like main in that only two id's there in future may be 3 id's there so I created 3 macro variables next I wrote&lt;/P&gt;
&lt;P&gt;One calculation I got var1 ,var2 results however for var3 I am getting error log window how to ignore that error.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2020 14:31:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-ignore-macro-variable-error/m-p/615937#M180225</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2020-01-08T14:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to ignore macro variable error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-ignore-macro-variable-error/m-p/615943#M180228</link>
      <description>&lt;P&gt;The &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p17npi7ti2jkidn1hw0fje3qqvph.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;SYMEXIST()&lt;/A&gt; function can be used to test if a macro variable exists.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2020 14:45:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-ignore-macro-variable-error/m-p/615943#M180228</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-01-08T14:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to ignore macro variable error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-ignore-macro-variable-error/m-p/615963#M180249</link>
      <description>&lt;P&gt;You could also consider defining "rate3" as a null macro variable at an earlier step. This should resolve the issue. If ID 103 is available "rate3" will be reassigned at the PROC SQL step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case you will get an empty VAR3 variable in data WANT even if ID 103 does not exist (not sure if you want that).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that you will need to check for missing rate3 value before deriving VAR3 to keep your code (completely) clean. Otherwise you will get a note for missing values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Include this before proc sql step*/
%let rate3 = ;&lt;BR /&gt;
/*update derivation of var3 to check for missing*/
if symgetn("rate3") ne . then var3=symgetn("rate3")*2 ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jan 2020 15:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-ignore-macro-variable-error/m-p/615963#M180249</guid>
      <dc:creator>geoskiad</dc:creator>
      <dc:date>2020-01-08T15:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to ignore macro variable error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-ignore-macro-variable-error/m-p/615994#M180260</link>
      <description>&lt;P&gt;The reason you are not seeing the macro variables is that the SELECT ... INTO ... process of SQL does NOT create macro variables when no observations are selected.&amp;nbsp; The easiest solution is just to set the macro variables to some default value before running the query.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let rate1=;
%let rate2=;
%let rate3=;
proc sql NOPRINT;
select score into :rate1-
  from main 
  where id in (101:103)
  order by id
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But it might just be better to not use macro variables at all.&amp;nbsp; Instead keep the values in dataset variables instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=main out=rates(drop=_name_) prefix=var ;
  var score ;
run;

data want ;
  set main ;
  if _n_=1 then set rates;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jan 2020 17:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-ignore-macro-variable-error/m-p/615994#M180260</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-08T17:47:55Z</dc:date>
    </item>
  </channel>
</rss>

