<?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 Help in my code  when using %symexist function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-in-my-code-when-using-symexist-function/m-p/641437#M191173</link>
    <description>&lt;LI-SPOILER&gt;
&lt;P&gt;data one;&lt;BR /&gt;input avalc $ aval;&lt;BR /&gt;datalines;&lt;BR /&gt;r1 1&lt;BR /&gt;r2 2&lt;BR /&gt;r3 3&lt;BR /&gt;r4 4&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql ;&lt;BR /&gt;select count(distinct avalc) into: cntt trimmed from one;&lt;BR /&gt;select distinct avalc into :param1 -:param&amp;amp;cntt. &lt;BR /&gt;from one;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;param1;&lt;BR /&gt;%put &amp;amp;param2;&lt;BR /&gt;%put &amp;amp;param3;&lt;BR /&gt;%put &amp;amp;param4;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data two three four six;&lt;BR /&gt;set one;&lt;BR /&gt;if avalc='r1' then output two;&lt;BR /&gt;if avalc='r2' then output three;&lt;BR /&gt;if avalc='r3' then output four;&lt;BR /&gt;if avalc='r4' then output six;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%macro want;&lt;BR /&gt;data final;&lt;BR /&gt;set two three %if %symexist (param3) %then %do; four;%end;&amp;nbsp; &amp;nbsp; %if %symexist (param4) %then %do; six; %end;;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;options mprint mlogic symbolgen;&lt;BR /&gt;%want;&lt;/P&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;Dear&lt;/P&gt;
&lt;P&gt;when I run macro(%want) at the bottom of my pgm i am getting error.&amp;nbsp; Please suggest Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output expected&amp;nbsp; from macro %want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data final;&lt;BR /&gt;set two three four six;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Apr 2020 18:08:28 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2020-04-20T18:08:28Z</dc:date>
    <item>
      <title>Help in my code  when using %symexist function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-my-code-when-using-symexist-function/m-p/641437#M191173</link>
      <description>&lt;LI-SPOILER&gt;
&lt;P&gt;data one;&lt;BR /&gt;input avalc $ aval;&lt;BR /&gt;datalines;&lt;BR /&gt;r1 1&lt;BR /&gt;r2 2&lt;BR /&gt;r3 3&lt;BR /&gt;r4 4&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql ;&lt;BR /&gt;select count(distinct avalc) into: cntt trimmed from one;&lt;BR /&gt;select distinct avalc into :param1 -:param&amp;amp;cntt. &lt;BR /&gt;from one;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;param1;&lt;BR /&gt;%put &amp;amp;param2;&lt;BR /&gt;%put &amp;amp;param3;&lt;BR /&gt;%put &amp;amp;param4;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data two three four six;&lt;BR /&gt;set one;&lt;BR /&gt;if avalc='r1' then output two;&lt;BR /&gt;if avalc='r2' then output three;&lt;BR /&gt;if avalc='r3' then output four;&lt;BR /&gt;if avalc='r4' then output six;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%macro want;&lt;BR /&gt;data final;&lt;BR /&gt;set two three %if %symexist (param3) %then %do; four;%end;&amp;nbsp; &amp;nbsp; %if %symexist (param4) %then %do; six; %end;;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;options mprint mlogic symbolgen;&lt;BR /&gt;%want;&lt;/P&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;Dear&lt;/P&gt;
&lt;P&gt;when I run macro(%want) at the bottom of my pgm i am getting error.&amp;nbsp; Please suggest Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output expected&amp;nbsp; from macro %want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data final;&lt;BR /&gt;set two three four six;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2020 18:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-my-code-when-using-symexist-function/m-p/641437#M191173</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2020-04-20T18:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help in my code  when using %symexist function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-my-code-when-using-symexist-function/m-p/641439#M191174</link>
      <description>&lt;P&gt;If you wanted that code then why did you insert those two extra semi-colons?&lt;/P&gt;
&lt;P&gt;Plus the %do/%end blocks seem like overkill.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro want;
data final;
  set two three 
%if %symexist (param3) %then four ;    
%if %symexist (param4) %then six ;
  ;
run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Apr 2020 18:13:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-my-code-when-using-symexist-function/m-p/641439#M191174</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-20T18:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help in my code  when using %symexist function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-my-code-when-using-symexist-function/m-p/641441#M191176</link>
      <description>&lt;P&gt;Since version 9.4M5, you do not need a macro definition, %if %then %do %end can be used in open code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data final;
set
  two
  three
%if %symexist (param3) %then %do; 
  four
%end;
%if %symexist (param4) %then %do;
  six
%end;
;
run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Apr 2020 18:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-my-code-when-using-symexist-function/m-p/641441#M191176</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-20T18:20:41Z</dc:date>
    </item>
  </channel>
</rss>

