<?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 Sub-setting data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sub-setting-data/m-p/723841#M224694</link>
    <description>&lt;P&gt;I have a dataset which has a variable name city which contains more than 100 city names. How can I create tables by subsetting data according to each city for all the unique city names in city variable.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Mar 2021 11:13:59 GMT</pubDate>
    <dc:creator>Ashokburnwal</dc:creator>
    <dc:date>2021-03-05T11:13:59Z</dc:date>
    <item>
      <title>Sub-setting data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sub-setting-data/m-p/723841#M224694</link>
      <description>&lt;P&gt;I have a dataset which has a variable name city which contains more than 100 city names. How can I create tables by subsetting data according to each city for all the unique city names in city variable.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 11:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sub-setting-data/m-p/723841#M224694</guid>
      <dc:creator>Ashokburnwal</dc:creator>
      <dc:date>2021-03-05T11:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sub-setting data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sub-setting-data/m-p/723845#M224697</link>
      <description>&lt;P&gt;Do you want to create datasets or tables (a report)?&lt;/P&gt;
&lt;P&gt;For the later: sort by "city" and use proc print with by-statement.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 11:29:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sub-setting-data/m-p/723845#M224697</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-03-05T11:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sub-setting data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sub-setting-data/m-p/723848#M224699</link>
      <description>Create datasets.&lt;BR /&gt;</description>
      <pubDate>Fri, 05 Mar 2021 12:01:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sub-setting-data/m-p/723848#M224699</guid>
      <dc:creator>Ashokburnwal</dc:creator>
      <dc:date>2021-03-05T12:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: Sub-setting data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sub-setting-data/m-p/723854#M224703</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/323864"&gt;@Ashokburnwal&lt;/a&gt;.,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following code attempts to do what you require, making use of the sashelp.class data step as input and splitting it up by sex.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* use sql to construct required data set names and output logic */
proc sql noprint;
   select distinct
       cat('ds_',sex)
      ,cat('when (', quote(sex), ') output ds_', sex)
   into
       :ds_names     separated by ' '
      ,:output_logic separated by ';'
   from
      sashelp.class
   ;
quit;

options symbolgen;

/* use the macro variables created in the sql in a data step with a select statement */
data &amp;amp;ds_names ds_issue;
   set sashelp.class;

   select(sex);
      &amp;amp;output_logic;
      otherwise output ds_issue;
   end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 13:11:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sub-setting-data/m-p/723854#M224703</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2021-03-05T13:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sub-setting data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sub-setting-data/m-p/723873#M224710</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/323864"&gt;@Ashokburnwal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Create datasets.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And why?&lt;/P&gt;
&lt;P&gt;Mind that in about 90% of cases, splitting a dataset is not needed.&lt;/P&gt;
&lt;P&gt;They only time in 20+ years of SAS work where I had to split a dataset was when it grew so much that sorting it in one piece cracked my quota in UTILLOC.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 14:18:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sub-setting-data/m-p/723873#M224710</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-05T14:18:59Z</dc:date>
    </item>
  </channel>
</rss>

