<?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 create multiple table from the observations of a single table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-multiple-table-from-the-observations-of-a-single/m-p/355483#M274048</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have a master table with columns EMP_ID , location and salary&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create separate table for each location with the columns&amp;nbsp;EMP_ID , location and salary&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can use the Proc SQL ; create table where location is "location name " &amp;nbsp;, but i have around 100 locations and for each location i have to crerate a separate tabe so its difficult to write the where clause 100 times in the proc sql&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there any other way to do this , kindly help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the master dataset is like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;EMP ID&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;LOCATIONS&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;SALARY&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;new york&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;20000&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;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D&gt;&lt;TD&gt;3000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;table bangalore&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;EMP ID&lt;/TD&gt;&lt;TD&gt;LOCATIONS&lt;/TD&gt;&lt;TD&gt;SALARY&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;bangalore&lt;/TD&gt;&lt;TD&gt;5000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;table delhi&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;EMP ID&lt;/TD&gt;&lt;TD&gt;LOCATIONS&lt;/TD&gt;&lt;TD&gt;SALARY&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;delhi&lt;/TD&gt;&lt;TD&gt;100000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Wed, 03 May 2017 05:50:27 GMT</pubDate>
    <dc:creator>soham_sas</dc:creator>
    <dc:date>2017-05-03T05:50:27Z</dc:date>
    <item>
      <title>how to create multiple table from the observations of a single table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-multiple-table-from-the-observations-of-a-single/m-p/355483#M274048</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have a master table with columns EMP_ID , location and salary&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create separate table for each location with the columns&amp;nbsp;EMP_ID , location and salary&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can use the Proc SQL ; create table where location is "location name " &amp;nbsp;, but i have around 100 locations and for each location i have to crerate a separate tabe so its difficult to write the where clause 100 times in the proc sql&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there any other way to do this , kindly help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the master dataset is like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;EMP ID&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;LOCATIONS&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;SALARY&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;new york&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;20000&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;mumbai&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;3000&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;bangalore&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;5000&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;delhi&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;100000&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want the tables to be created like below&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;table new york&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;EMP ID&lt;/TD&gt;&lt;TD&gt;LOCATIONS&lt;/TD&gt;&lt;TD&gt;SALARY&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;new york&lt;/TD&gt;&lt;TD&gt;20000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;table mumbai&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;EMP ID&lt;/TD&gt;&lt;TD&gt;LOCATIONS&lt;/TD&gt;&lt;TD&gt;SALARY&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;mumbai&lt;/TD&gt;&lt;TD&gt;3000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;table bangalore&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;EMP ID&lt;/TD&gt;&lt;TD&gt;LOCATIONS&lt;/TD&gt;&lt;TD&gt;SALARY&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;bangalore&lt;/TD&gt;&lt;TD&gt;5000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;table delhi&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;EMP ID&lt;/TD&gt;&lt;TD&gt;LOCATIONS&lt;/TD&gt;&lt;TD&gt;SALARY&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;delhi&lt;/TD&gt;&lt;TD&gt;100000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 03 May 2017 05:50:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-multiple-table-from-the-observations-of-a-single/m-p/355483#M274048</guid>
      <dc:creator>soham_sas</dc:creator>
      <dc:date>2017-05-03T05:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to create multiple table from the observations of a single table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-multiple-table-from-the-observations-of-a-single/m-p/355495#M274049</link>
      <description>&lt;P&gt;What for? If you need analytics done on groups, use by-processing or a where condition. Putting data (location names) in structure (dataset names) will only make your life harder.&lt;/P&gt;
&lt;P&gt;See Maxim 19.&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 06:40:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-multiple-table-from-the-observations-of-a-single/m-p/355495#M274049</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-03T06:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to create multiple table from the observations of a single table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-multiple-table-from-the-observations-of-a-single/m-p/355537#M274050</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;i am not using any analytics for this , the situations is like , i have to share the individually created table to each locatin separately&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in a bulk i can't send because i contains some confidential data&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;kindly help for a solution ..&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 10:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-multiple-table-from-the-observations-of-a-single/m-p/355537#M274050</guid>
      <dc:creator>soham_sas</dc:creator>
      <dc:date>2017-05-03T10:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to create multiple table from the observations of a single table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-multiple-table-from-the-observations-of-a-single/m-p/355541#M274051</link>
      <description>&lt;P&gt;First of all, you need to be aware that using strings from data in file/dataset names might have unexpected side effects. Datasets in particular have a 32 character name limit, and no characters apart from a-z,0-9,_ are allowed. So you need to adapt your location variable first by using translation functions.&lt;/P&gt;
&lt;P&gt;Then you can do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort
  data=have (keep=location)
  out=lookup
  nodupkey
;
by location;
run;

data _null_;
call execute('data ');
do until(eof1);
  set lookup end=eof1;
  call execute(trim(location) !! ' ');
end;
call execute('; set have; select (location);');
do until(eof2);
  set lookup end=eof2;
  call execute('when("' !! trim(location) !! '") output ' !! trim(location) !! ';');
end;
call execute('end; run;')
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This creates a data step dynamically from your lookup data and will need just two passes (one sort, one final) through the master dataset.&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 10:53:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-multiple-table-from-the-observations-of-a-single/m-p/355541#M274051</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-03T10:53:43Z</dc:date>
    </item>
  </channel>
</rss>

