<?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 Deleting Certain Categories within a Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Deleting-Certain-Categories-within-a-Variable/m-p/90877#M257316</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a categorical variable, labelled 0-9. I need to delete certain values so I can run a CHISQ.&lt;/P&gt;&lt;P&gt;This is what I'm trying, but with no luck:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt;&lt;/SPAN&gt; mn.lahrt; *my dataset*&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp; &lt;SPAN class="s2"&gt;SET&lt;/SPAN&gt; IHD_DX; *the variable name*&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp; &lt;SPAN class="s2"&gt;IF&lt;/SPAN&gt; IHD_DX = &lt;SPAN class="s3"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;THEN&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;delete&lt;/SPAN&gt;;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp; &lt;SPAN class="s2"&gt;IF&lt;/SPAN&gt; IHD_DX = &lt;SPAN class="s3"&gt;&lt;STRONG&gt;8&lt;/STRONG&gt;&lt;/SPAN&gt; and &lt;SPAN class="s3"&gt;&lt;STRONG&gt;9&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;Then&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;delete&lt;/SPAN&gt;;&lt;/P&gt;&lt;P class="p2"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;SPAN class="s4"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s4"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s4"&gt;I need to keep categories 1-7 only (which are further split in only two categories).&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s4"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s4"&gt;Any suggestions?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 23 Jun 2012 06:26:00 GMT</pubDate>
    <dc:creator>MN</dc:creator>
    <dc:date>2012-06-23T06:26:00Z</dc:date>
    <item>
      <title>Deleting Certain Categories within a Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-Certain-Categories-within-a-Variable/m-p/90877#M257316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a categorical variable, labelled 0-9. I need to delete certain values so I can run a CHISQ.&lt;/P&gt;&lt;P&gt;This is what I'm trying, but with no luck:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt;&lt;/SPAN&gt; mn.lahrt; *my dataset*&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp; &lt;SPAN class="s2"&gt;SET&lt;/SPAN&gt; IHD_DX; *the variable name*&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp; &lt;SPAN class="s2"&gt;IF&lt;/SPAN&gt; IHD_DX = &lt;SPAN class="s3"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;THEN&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;delete&lt;/SPAN&gt;;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp; &lt;SPAN class="s2"&gt;IF&lt;/SPAN&gt; IHD_DX = &lt;SPAN class="s3"&gt;&lt;STRONG&gt;8&lt;/STRONG&gt;&lt;/SPAN&gt; and &lt;SPAN class="s3"&gt;&lt;STRONG&gt;9&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;Then&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;delete&lt;/SPAN&gt;;&lt;/P&gt;&lt;P class="p2"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;SPAN class="s4"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s4"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s4"&gt;I need to keep categories 1-7 only (which are further split in only two categories).&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s4"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s4"&gt;Any suggestions?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Jun 2012 06:26:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-Certain-Categories-within-a-Variable/m-p/90877#M257316</guid>
      <dc:creator>MN</dc:creator>
      <dc:date>2012-06-23T06:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Certain Categories within a Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-Certain-Categories-within-a-Variable/m-p/90878#M257317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;Try this..Hope it helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="p1" style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN class="s1" style="font-style: inherit; font-family: inherit;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;DATA&lt;/STRONG&gt;&lt;/SPAN&gt; mn.lahrt; &lt;/P&gt;&lt;P class="p1" style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; &lt;SPAN class="s2" style="font-style: inherit; font-family: inherit;"&gt;SET&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt; mn.lahrt&lt;/SPAN&gt;&lt;/SPAN&gt;; &lt;/P&gt;&lt;P class="p1" style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; &lt;SPAN class="s2" style="font-style: inherit; font-family: inherit;"&gt;IF&lt;/SPAN&gt; IHD_DX&amp;nbsp; in ('&lt;SPAN class="s3" style="font-style: inherit; font-family: inherit;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;0','8','9')&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s2" style="font-style: inherit; font-family: inherit;"&gt;THEN&lt;/SPAN&gt; &lt;SPAN class="s2" style="font-style: inherit; font-family: inherit;"&gt;delete&lt;/SPAN&gt;;&lt;/P&gt;&lt;P class="p1" style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;RUN&lt;/STRONG&gt;&lt;SPAN class="s4" style="font-style: inherit; font-family: inherit;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1" style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P class="p1" style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Thanks,&lt;/P&gt;&lt;P class="p1" style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Jun 2012 06:58:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-Certain-Categories-within-a-Variable/m-p/90878#M257317</guid>
      <dc:creator>shivas</dc:creator>
      <dc:date>2012-06-23T06:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Certain Categories within a Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-Certain-Categories-within-a-Variable/m-p/90879#M257318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your language is very confused.&amp;nbsp; Sounds to me like you have a variable named IHD_DX in a dataset named MN.LAHRT.&lt;/P&gt;&lt;P&gt;You would not normally want to overwrite your input dataset as in your example code.&amp;nbsp; In fact to limit data you can just use a WHERE statement in your procedure calls.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=mn.lahrt ;&lt;/P&gt;&lt;P&gt; where 1&amp;lt;= idh_dx &amp;lt;= 7 ;&lt;/P&gt;&lt;P&gt; tables idh_dx / chisq ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not sure what you mean by "labeled" values. Is it possible that the actual values in IDH_DX variable are something other than the values 0,1,....9 ?&amp;nbsp; Do you have a format attached?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also use formats to temporarily regroup you data for a PROC FREQ call.&amp;nbsp; For example if you want to regroup your values into two groups you might use something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format ;&lt;/P&gt;&lt;P&gt; value group 1-7 = 'VALID' other='INVALID';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc freq data=mn.lahrt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format idh_dx group.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; tables idh_dx;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Jun 2012 18:27:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-Certain-Categories-within-a-Variable/m-p/90879#M257318</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-06-23T18:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Certain Categories within a Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-Certain-Categories-within-a-Variable/m-p/90880#M257319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank You for your help. Though that didn't really work for my data-set, so I just exported it to excel and made the needed changes. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Jun 2012 07:34:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-Certain-Categories-within-a-Variable/m-p/90880#M257319</guid>
      <dc:creator>MN</dc:creator>
      <dc:date>2012-06-24T07:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Certain Categories within a Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-Certain-Categories-within-a-Variable/m-p/90881#M257320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank You for your help. Though that didn't really work for my data-set, so I just exported it to excel and made the needed changes. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Jun 2012 07:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-Certain-Categories-within-a-Variable/m-p/90881#M257320</guid>
      <dc:creator>MN</dc:creator>
      <dc:date>2012-06-24T07:35:03Z</dc:date>
    </item>
  </channel>
</rss>

