<?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: Creating subgroups while keeping group in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Creating-subgroups-while-keeping-group/m-p/608701#M17743</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301930"&gt;@SivaKizildag&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You face this issue because the variable for grouping is the same name as variable for subgrouping. So if statements for subgrouping erase the first one for grouping. As only "06" is not referenced for subgrouping, the variable for grouping contains only this value (not erased).&lt;/P&gt;
&lt;P&gt;You should create another variable for subgrouping. I also encourage you to use "else if" in your statements to have a more efficient code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp; set in.data;

if sect in ('01' '02' '03' '04' '05' '06')    then my_sector='Industry' ;

if		sect in ('01' '02')    then my_subsector='Textile Industry' ;
else if sect in ('03' '04')    then my_subsector='Food Industry' ;
else if sect in ('05')         then my_subsector='Mining Industry' ;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
    <pubDate>Mon, 02 Dec 2019 13:51:32 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2019-12-02T13:51:32Z</dc:date>
    <item>
      <title>Creating subgroups while keeping group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-subgroups-while-keeping-group/m-p/608674#M17730</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset, where each row contains information about firms. There is a variable about the sector of the company; &lt;STRONG&gt;sect&lt;/STRONG&gt;. There are up to 700 sectors, so I need to group them, like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Industry: mining, textiles industry, food industry... and so on. I do this with the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp; set in.data;

if sect in ('01' '02' '03' '04' '05' '06')&amp;nbsp;&amp;nbsp;&amp;nbsp; then my_sector='Industry' ;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The tricky part is ; I also want to give out details within each sector. For instance, I want to keep this whole "Industry" sector, but I also want to have subgroups within "Industry". But when I run the following code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp; set in.data;

if sect in ('01' '02' '03' '04' '05' '06')&amp;nbsp;&amp;nbsp;&amp;nbsp; then my_sector='Industry' ;

if sect in ('01' '02')&amp;nbsp;&amp;nbsp;&amp;nbsp; then my_sector='Textile Industry' ;
if sect in ('03' '04')&amp;nbsp;&amp;nbsp;&amp;nbsp; then my_sector='Food Industry' ;
if sect in ('05')&amp;nbsp;&amp;nbsp;&amp;nbsp;      then my_sector='Mining Industry' ;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The subgroups work just fine, but the global "Industry" sector only contains what is not contained in other subgroups (here the sector 06). So mu question is; how do I have the 3 subgroups but also an "Industry" sector that has all the 3 subgroups and the rest of the industry (from 01 to 06)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 11:29:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-subgroups-while-keeping-group/m-p/608674#M17730</guid>
      <dc:creator>SivaKizildag</dc:creator>
      <dc:date>2019-12-02T11:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating subgroups while keeping group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-subgroups-while-keeping-group/m-p/608700#M17742</link>
      <description>Simply create a 2nd field that contains the 2nd grouping.</description>
      <pubDate>Mon, 02 Dec 2019 13:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-subgroups-while-keeping-group/m-p/608700#M17742</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2019-12-02T13:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Creating subgroups while keeping group</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-subgroups-while-keeping-group/m-p/608701#M17743</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301930"&gt;@SivaKizildag&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You face this issue because the variable for grouping is the same name as variable for subgrouping. So if statements for subgrouping erase the first one for grouping. As only "06" is not referenced for subgrouping, the variable for grouping contains only this value (not erased).&lt;/P&gt;
&lt;P&gt;You should create another variable for subgrouping. I also encourage you to use "else if" in your statements to have a more efficient code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp; set in.data;

if sect in ('01' '02' '03' '04' '05' '06')    then my_sector='Industry' ;

if		sect in ('01' '02')    then my_subsector='Textile Industry' ;
else if sect in ('03' '04')    then my_subsector='Food Industry' ;
else if sect in ('05')         then my_subsector='Mining Industry' ;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 13:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-subgroups-while-keeping-group/m-p/608701#M17743</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-02T13:51:32Z</dc:date>
    </item>
  </channel>
</rss>

