<?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 I want to create the separate datasets for each location, when number of locations are not specified in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-create-the-separate-datasets-for-each-location-when/m-p/394422#M95038</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if user dont know&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;how many locations are there in input, then how can we write a code in SAS&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Task :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;input emp_id&amp;nbsp; name$ loc$;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 srinivas bang&lt;/P&gt;&lt;P&gt;2 sudhakar bang&lt;/P&gt;&lt;P&gt;3 qqqq hyd&lt;/P&gt;&lt;P&gt;4 hhhh hyd&lt;/P&gt;&lt;P&gt;5 bhanu mumbai&lt;/P&gt;&lt;P&gt;6 jjjjj mumbai&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Solution:;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA Bang;&lt;/P&gt;&lt;P&gt;&amp;nbsp;set one(where=(loc='bang'));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;DATA Hyd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;set one(where=(loc='hyd'));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;DATA Mumbai;&lt;/P&gt;&lt;P&gt;&amp;nbsp;set one(where=(loc='mumbai'));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 09 Sep 2017 06:40:34 GMT</pubDate>
    <dc:creator>Kusuma001</dc:creator>
    <dc:date>2017-09-09T06:40:34Z</dc:date>
    <item>
      <title>I want to create the separate datasets for each location, when number of locations are not specified</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-create-the-separate-datasets-for-each-location-when/m-p/394422#M95038</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if user dont know&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;how many locations are there in input, then how can we write a code in SAS&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Task :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;input emp_id&amp;nbsp; name$ loc$;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 srinivas bang&lt;/P&gt;&lt;P&gt;2 sudhakar bang&lt;/P&gt;&lt;P&gt;3 qqqq hyd&lt;/P&gt;&lt;P&gt;4 hhhh hyd&lt;/P&gt;&lt;P&gt;5 bhanu mumbai&lt;/P&gt;&lt;P&gt;6 jjjjj mumbai&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Solution:;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA Bang;&lt;/P&gt;&lt;P&gt;&amp;nbsp;set one(where=(loc='bang'));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;DATA Hyd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;set one(where=(loc='hyd'));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;DATA Mumbai;&lt;/P&gt;&lt;P&gt;&amp;nbsp;set one(where=(loc='mumbai'));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Sep 2017 06:40:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-create-the-separate-datasets-for-each-location-when/m-p/394422#M95038</guid>
      <dc:creator>Kusuma001</dc:creator>
      <dc:date>2017-09-09T06:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: I want to create the separate datasets for each location, when number of locations are not speci</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-create-the-separate-datasets-for-each-location-when/m-p/394430#M95043</link>
      <description>&lt;P&gt;If you search 'split data into subsets' you'll find many solutions. Note that this is rarely recommended in SAS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/sasdummy/2015/01/26/how-to-split-one-data-set-into-many/" target="_blank"&gt;http://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, 09 Sep 2017 11:55:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-create-the-separate-datasets-for-each-location-when/m-p/394430#M95043</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-09T11:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: I want to create the separate datasets for each location, when number of locations are not speci</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-create-the-separate-datasets-for-each-location-when/m-p/394431#M95044</link>
      <description>&lt;P&gt;If you dont know how any locations are in your data step, this HASH object solution works well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input emp_id  name$ loc$;
datalines;
1 srinivas bang
2 sudhakar bang
3 qqqq hyd
4 hhhh hyd
5 bhanu mumbai
6 jjjjj mumbai
;

proc sort data=one;
   by loc;
run;

data _null_;
   if _n_=1 then do;
   if 0 then set one;
   declare hash h(dataset:"one(obs=0)", multidata:'y');
      h.definekey(all:'y');
      h.definedata(all:'y');
      h.definedone();
   end;
   do until(last.loc);
      set one;
      by loc;
      h.add();
   end;
   h.output(dataset:loc);
   h.clear();
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://sasnrd.com/split-data-by-group/&amp;nbsp;" target="_blank"&gt;http://sasnrd.com/split-data-by-group/&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Sep 2017 15:42:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-create-the-separate-datasets-for-each-location-when/m-p/394431#M95044</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-09-17T15:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: I want to create the separate datasets for each location, when number of locations are not speci</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-create-the-separate-datasets-for-each-location-when/m-p/394433#M95045</link>
      <description>&lt;P&gt;It works!! Thank you so much &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Sep 2017 12:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-create-the-separate-datasets-for-each-location-when/m-p/394433#M95045</guid>
      <dc:creator>Kusuma001</dc:creator>
      <dc:date>2017-09-09T12:35:24Z</dc:date>
    </item>
  </channel>
</rss>

