<?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: Append the data based on conditional statements in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Append-the-data-based-on-conditional-statements/m-p/522212#M141743</link>
    <description>Thanks for your inputs got to solve it</description>
    <pubDate>Tue, 18 Dec 2018 13:41:52 GMT</pubDate>
    <dc:creator>NagendraBS</dc:creator>
    <dc:date>2018-12-18T13:41:52Z</dc:date>
    <item>
      <title>Append the data based on conditional statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-the-data-based-on-conditional-statements/m-p/522192#M141731</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I have 3 datasets seperately&lt;BR /&gt;&lt;BR /&gt;Data A;&lt;BR /&gt;Input Name $&lt;BR /&gt;Cards;&lt;BR /&gt;ABC&lt;BR /&gt;Bcd&lt;BR /&gt;Cde&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;Data B;&lt;BR /&gt;Input name $;&lt;BR /&gt;Cards;&lt;BR /&gt;Wer&lt;BR /&gt;Try&lt;BR /&gt;Uni&lt;BR /&gt;; run;&lt;BR /&gt;&lt;BR /&gt;Data C;&lt;BR /&gt;Input name $;&lt;BR /&gt;Cards;&lt;BR /&gt;Gfh&lt;BR /&gt;Hij&lt;BR /&gt;Klm&lt;BR /&gt;; run;&lt;BR /&gt;&lt;BR /&gt;So I need the output based on condition with macro variable value.&lt;BR /&gt;Let say if city = blr then dataset A should append and if city = hyd then dataset B should append to base dataset and if city is blank then dataset C should append to base dataset.&lt;BR /&gt;&lt;BR /&gt;Here is the code I have tried on.&lt;BR /&gt;&lt;BR /&gt;%let city = blr;&lt;BR /&gt;&lt;BR /&gt;Data new;&lt;BR /&gt;If city = "blr" then set A end=done;&lt;BR /&gt;Else if city = "hyd" the set B end=done;&lt;BR /&gt;Else set C end=done;&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;Here I see all the records are populating.&lt;BR /&gt;&lt;BR /&gt;Please provide Ur inputs to recreate the code.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.</description>
      <pubDate>Tue, 18 Dec 2018 13:03:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-the-data-based-on-conditional-statements/m-p/522192#M141731</guid>
      <dc:creator>NagendraBS</dc:creator>
      <dc:date>2018-12-18T13:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Append the data based on conditional statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-the-data-based-on-conditional-statements/m-p/522196#M141734</link>
      <description>&lt;P&gt;Please post an actual example.&amp;nbsp; Why would you have a macro variable which indirectly points the data to append?&amp;nbsp; I mean you could do:&lt;/P&gt;
&lt;PRE&gt;%macro appnd ();
  data want;
    set a
  %if "&amp;amp;city."="blr" %then %do;
    b;
  %end;
  %else %do;
    c;
  %end;
  run;
%mend appnd;

%appnd;&lt;/PRE&gt;
&lt;P&gt;But you could vastly simplfy it just by having the macro variable point to the actual table you want to append:&lt;/P&gt;
&lt;PRE&gt;%let city=b;

data want;
  set a &amp;amp;city.;
run;&lt;/PRE&gt;
&lt;P&gt;I suppose the key question here is why your doing this at all.&amp;nbsp; The data should have all the information needed, i.e. a variable in there for filtering.&amp;nbsp; So you would simply do:&lt;/P&gt;
&lt;PRE&gt;data want;
  set a b c;
  where city="blr";
run;&lt;/PRE&gt;
&lt;P&gt;I think your just complicating the whole thing.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Dec 2018 13:14:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-the-data-based-on-conditional-statements/m-p/522196#M141734</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-18T13:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Append the data based on conditional statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-the-data-based-on-conditional-statements/m-p/522204#M141737</link>
      <description>Hi RW9,&lt;BR /&gt;&lt;BR /&gt;I'll make it simple example based on macro value I need to append the data let say &lt;BR /&gt;%let Var = A;&lt;BR /&gt;&lt;BR /&gt;Dataset A should get appended and if the macro variable is blank then Dataset C should append &lt;BR /&gt;It is like if u have variable value append that respective dataset and if variable value is blank the by default need to append the dataset C. &lt;BR /&gt;</description>
      <pubDate>Tue, 18 Dec 2018 13:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-the-data-based-on-conditional-statements/m-p/522204#M141737</guid>
      <dc:creator>NagendraBS</dc:creator>
      <dc:date>2018-12-18T13:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: Append the data based on conditional statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-the-data-based-on-conditional-statements/m-p/522207#M141739</link>
      <description>&lt;P&gt;Maybe:&lt;/P&gt;
&lt;PRE&gt;data want;
  set %sysfunc(coalescec(&amp;amp;var.,C));
run;&lt;/PRE&gt;
&lt;P&gt;This will set the first if non-missing, otherwise c.&amp;nbsp; I still don't see any value in this approach however.&amp;nbsp; macro is not for data processing, put data in the dataset, then use where filtering its quicker, uses less resources, and is simpler coding.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Dec 2018 13:35:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-the-data-based-on-conditional-statements/m-p/522207#M141739</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-18T13:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Append the data based on conditional statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-the-data-based-on-conditional-statements/m-p/522212#M141743</link>
      <description>Thanks for your inputs got to solve it</description>
      <pubDate>Tue, 18 Dec 2018 13:41:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-the-data-based-on-conditional-statements/m-p/522212#M141743</guid>
      <dc:creator>NagendraBS</dc:creator>
      <dc:date>2018-12-18T13:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Append the data based on conditional statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-the-data-based-on-conditional-statements/m-p/522219#M141746</link>
      <description>&lt;P&gt;Cool, please remember to mark appropriate posts as the answer when you have what you need.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Dec 2018 14:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-the-data-based-on-conditional-statements/m-p/522219#M141746</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-18T14:07:26Z</dc:date>
    </item>
  </channel>
</rss>

