<?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: Create categories in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505352#M1146</link>
    <description>Thankyou very much this is very helpful&lt;BR /&gt;&lt;BR /&gt;I used method 2&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 17 Oct 2018 21:15:13 GMT</pubDate>
    <dc:creator>Ranjeeta</dc:creator>
    <dc:date>2018-10-17T21:15:13Z</dc:date>
    <item>
      <title>Create categories</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505338#M1139</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a column of time in minutes ranging from 0 to 1440 minutes&lt;/P&gt;&lt;P&gt;I want to create 2 categories for this data in sas&lt;/P&gt;&lt;P&gt;360&amp;lt; Category 1 &amp;gt;=0&amp;nbsp; minutes and&lt;/P&gt;&lt;P&gt;1440&amp;lt; Category 2 &amp;gt;=360 minutes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please advise what sas commands would I use to achieve the above result&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 20:43:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505338#M1139</guid>
      <dc:creator>Ranjeeta</dc:creator>
      <dc:date>2018-10-17T20:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create categories</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505342#M1140</link>
      <description>&lt;P&gt;Hi and welcome to the SAS community &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does your actual data contain only two categories? Or more?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If just the two, do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   do time=1 to 2000;
      output;
   end;
run;

data want;
   set have;
   Category=ifc((0 &amp;lt;= time &amp;lt;=360), "Category 1", "Category 2");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Oct 2018 20:54:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505342#M1140</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-10-17T20:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Create categories</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505345#M1141</link>
      <description>&lt;P&gt;Thankyou !!&lt;/P&gt;&lt;P&gt;Yes and&amp;nbsp;These are the only two categories that I want to create&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 20:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505345#M1141</guid>
      <dc:creator>Ranjeeta</dc:creator>
      <dc:date>2018-10-17T20:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create categories</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505346#M1142</link>
      <description>&lt;P&gt;Ok. I have edited the above answer with a small code example.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know if it fits your needs&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 20:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505346#M1142</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-10-17T20:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create categories</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505347#M1143</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use case when expression in proc sql or If then in data step or else you can also use proc format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Method 1*/
proc sql;
select *, case when 0&amp;lt;=time&amp;lt;360 then "Cat 1"
			   when 360&amp;lt;=time&amp;lt;1440 then "Cat 2"
			   else "NA" end as cat
	from have;
quit;
/* Method 2*/
data want ;
set have;
if  0&amp;lt;=time&amp;lt;360 then cat="Cat 1";
else if 360&amp;lt;=time&amp;lt;1440 then cat="Cat 2";
else cat='NA';
run;
/* Method 3*/
proc format;
value timevar 0-360="cat1"
			  360-above="cat 2";
run;

data want;
set have;
format time_variable timevar.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Oct 2018 21:02:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505347#M1143</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-10-17T21:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create categories</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505352#M1146</link>
      <description>Thankyou very much this is very helpful&lt;BR /&gt;&lt;BR /&gt;I used method 2&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Oct 2018 21:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505352#M1146</guid>
      <dc:creator>Ranjeeta</dc:creator>
      <dc:date>2018-10-17T21:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create categories</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505356#M1147</link>
      <description>&lt;P&gt;Thankyou for your response&amp;nbsp; Im new to sas therefore used if then /else as Im familiar&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will try the IFC function as well&lt;/P&gt;</description>
      <pubDate>Wed, 17 Oct 2018 21:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-categories/m-p/505356#M1147</guid>
      <dc:creator>Ranjeeta</dc:creator>
      <dc:date>2018-10-17T21:17:26Z</dc:date>
    </item>
  </channel>
</rss>

