<?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: Macro - To create multiple dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491905#M129155</link>
    <description>&lt;OL&gt;
&lt;LI&gt;Macro triggers are not evaluated inside of single quotes. Also dataset names do not have quotes in them.&lt;/LI&gt;
&lt;LI&gt;You are not using your looping variable inside the loop.&lt;/LI&gt;
&lt;LI&gt;You need to delay the evaluation of the first &amp;amp; until after the loop number has been evaluate. So double the first &amp;amp;.&lt;/LI&gt;
&lt;/OL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i =1 %to &amp;amp;sqlobs;
data out_&amp;amp;&amp;amp;country&amp;amp;i ;
  set have(where=(country="&amp;amp;&amp;amp;country&amp;amp;i"));
run;
%end;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 02 Sep 2018 17:03:26 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-09-02T17:03:26Z</dc:date>
    <item>
      <title>Macro - To create multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491844#M129106</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need some of your help on the below scenario:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#1)&amp;nbsp; I have data like below and need to create multiple dataset using macro based on the country, so need to create 5 different datasets Can someone provide a good approach for this ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EmpID&amp;nbsp; Amount Country&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $200&amp;nbsp; &amp;nbsp;US&lt;/P&gt;&lt;P&gt;456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $300&amp;nbsp; India&lt;/P&gt;&lt;P&gt;678&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $500&amp;nbsp; China&lt;/P&gt;&lt;P&gt;980&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $300&amp;nbsp; Japan&lt;/P&gt;&lt;P&gt;700&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $600&amp;nbsp; &amp;nbsp;Singapore&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#2)&amp;nbsp; I have a data like below and need to pull the highlighted rows since age is different in the 3rd transaction when compared to 1st and 2nd transaction. I tried self join ,it's working fine but do we have anyother way in datastep ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EmpID&amp;nbsp; TrnsctID&amp;nbsp; Age&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 900&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 500&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 400&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;28&lt;/P&gt;&lt;P&gt;987&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 300&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;27&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 200&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;28&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Sep 2018 20:05:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491844#M129106</guid>
      <dc:creator>AshokD</dc:creator>
      <dc:date>2018-09-01T20:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - To create multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491848#M129108</link>
      <description>&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/Split_Data_into_Subsets" target="_blank"&gt;http://www.sascommunity.org/wiki/Split_Data_into_Subsets&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Sep 2018 20:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491848#M129108</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-01T20:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - To create multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491855#M129113</link>
      <description>&lt;P&gt;Regarding #2 you can use FIRST/LAST logic with BY groups.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would be looking for the:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if first.age and not first.empID;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/56202"&gt;@AshokD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need some of your help on the below scenario:-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;#1)&amp;nbsp; I have data like below and need to create multiple dataset using macro based on the country, so need to create 5 different datasets Can someone provide a good approach for this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EmpID&amp;nbsp; Amount Country&lt;/P&gt;
&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $200&amp;nbsp; &amp;nbsp;US&lt;/P&gt;
&lt;P&gt;456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $300&amp;nbsp; India&lt;/P&gt;
&lt;P&gt;678&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $500&amp;nbsp; China&lt;/P&gt;
&lt;P&gt;980&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $300&amp;nbsp; Japan&lt;/P&gt;
&lt;P&gt;700&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $600&amp;nbsp; &amp;nbsp;Singapore&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;#2)&amp;nbsp; I have a data like below and need to pull the highlighted rows since age is different in the 3rd transaction when compared to 1st and 2nd transaction. I tried self join ,it's working fine but do we have anyother way in datastep ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EmpID&amp;nbsp; TrnsctID&amp;nbsp; Age&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 900&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 500&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 400&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;28&lt;/P&gt;
&lt;P&gt;987&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 300&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;27&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 200&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;28&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Sep 2018 22:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491855#M129113</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-01T22:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - To create multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491880#M129133</link>
      <description>&lt;P&gt;For the second question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input EmpID  TrnsctID  Age;
cards;
123        900         30
123        500         30
567        400         28
987        300         27
123        200         28
;
run;

proc sql;
create table want as
 select *
  from have 
   group by EmpID
    having count(distinct Age) &amp;gt; 1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Sep 2018 10:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491880#M129133</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-09-02T10:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - To create multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491892#M129145</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your inputs.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Sep 2018 15:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491892#M129145</guid>
      <dc:creator>AshokD</dc:creator>
      <dc:date>2018-09-02T15:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - To create multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491904#M129154</link>
      <description>&lt;P&gt;data have;&lt;BR /&gt;length Country $30.;&lt;BR /&gt;input EmpID Trnsct Country $;&lt;BR /&gt;cards;&lt;BR /&gt;123 200 US&lt;BR /&gt;456 300 India&lt;BR /&gt;678 500 China&lt;BR /&gt;980 300 Japan&lt;BR /&gt;700 600 Singapore&lt;BR /&gt;800 240 US&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%macro a;&lt;BR /&gt;option mprint mlogic symbolgen;&lt;BR /&gt;proc sql;&lt;BR /&gt;select distinct country&lt;BR /&gt;into :country1 - :country99&lt;BR /&gt;from have;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%put &amp;amp;country1 &amp;amp;country2 &amp;amp;country3 &amp;amp;country4 &amp;amp;country5 &amp;amp;sqlobs;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%do i =1 %to &amp;amp;sqlobs;&lt;BR /&gt;DATA out_'&amp;amp;country..&amp;amp;sqlobs..';&lt;BR /&gt;set have(where=(country='&amp;amp;country.&amp;amp;sqlobs.'));&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%mend a;&lt;BR /&gt;%a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm facing issue in resolving the macro to split the dataset. Can someone help&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Sep 2018 16:52:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491904#M129154</guid>
      <dc:creator>AshokD</dc:creator>
      <dc:date>2018-09-02T16:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - To create multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491905#M129155</link>
      <description>&lt;OL&gt;
&lt;LI&gt;Macro triggers are not evaluated inside of single quotes. Also dataset names do not have quotes in them.&lt;/LI&gt;
&lt;LI&gt;You are not using your looping variable inside the loop.&lt;/LI&gt;
&lt;LI&gt;You need to delay the evaluation of the first &amp;amp; until after the loop number has been evaluate. So double the first &amp;amp;.&lt;/LI&gt;
&lt;/OL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i =1 %to &amp;amp;sqlobs;
data out_&amp;amp;&amp;amp;country&amp;amp;i ;
  set have(where=(country="&amp;amp;&amp;amp;country&amp;amp;i"));
run;
%end;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Sep 2018 17:03:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491905#M129155</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-09-02T17:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - To create multiple dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491907#M129157</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works, Thanks for the help.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Sep 2018 17:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-To-create-multiple-dataset/m-p/491907#M129157</guid>
      <dc:creator>AshokD</dc:creator>
      <dc:date>2018-09-02T17:29:29Z</dc:date>
    </item>
  </channel>
</rss>

