<?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: Combining categories in SAS in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Combining-categories-in-SAS/m-p/806119#M39670</link>
    <description>&lt;P&gt;You can't use IF statements in PROC FORMAT. The proper syntax is shown &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p1upn25lbfo6mkn1wncu4dyh9q91.htm" target="_blank"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A better approach (maybe):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    length group $ 6;
    if CRCLSCOD=:'A' or CRCLSCOD=:'B' then group='GOOD';
    else if CRCLSCOD=:'C' or CRCLSCOD=:'D' then group='Medium';
    else group='Bad';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Apr 2022 18:17:32 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-04-05T18:17:32Z</dc:date>
    <item>
      <title>Combining categories in SAS</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Combining-categories-in-SAS/m-p/806118#M39669</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a variable (CRCLSCOD) that have 54 categories. I want to regroup the categories as follow:&lt;/P&gt;&lt;P&gt;Good : A A2 A3 AA B B2 BA&lt;/P&gt;&lt;P&gt;Medium : C C2 C5 CA CC CY D D2 D4 D5 DA&lt;/P&gt;&lt;P&gt;Bad: E E2 E4 EA EC EF EM G GA GY H I IF J JF K L M O P1 S TP U U1 V V1 W Y Z Z1 Z2 Z4 Z5 ZA ZF ZY&lt;/P&gt;&lt;P&gt;Data dm.churn;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;Proc format;&lt;BR /&gt;Value CRCLSCOD;&lt;BR /&gt;if CRCLSCOD="A" or CRCLSCOD="A2" or CRCLSCOD="A3" or CRCLSCOD="AA" or CRCLSCOD="B" or CRCLSCOD="B2" or CRCLSCOD="BA" THEN Good=1;&lt;BR /&gt;IF CRCLSCOD="C" or CRCLSCOD="C2" or CRCLSCOD="C5" or CRCLSCOD="CA" or CRCLSCOD="CC" or CRCLSCOD="CY" or CRCLSCOD="D" or CRCLSCOD="D2" or CRCLSCOD="D4" or CRCLSCOD="D5" or CRCLSCOD="DA" THEN Medium=1;&lt;BR /&gt;IF CRCLSCOD="E" or CRCLSCOD="E2" or CRCLSCOD="E4" or CRCLSCOD="EA" or CRCLSCOD="EC" or CRCLSCOD="EF" or CRCLSCOD="EM" or CRCLSCOD="G" or CRCLSCOD="GA" or CRCLSCOD="GY" or CRCLSCOD="H" or CRCLSCOD="I" or CRCLSCOD="IF" or CRCLSCOD="J" or CRCLSCOD="JF" or CRCLSCOD="K" or CRCLSCOD="L" or CRCLSCOD="M" or CRCLSCOD="O" or CRCLSCOD="P1" or CRCLSCOD="S" or CRCLSCOD="TP" or CRCLSCOD="U" or CRCLSCOD="U1" or CRCLSCOD="V" or CRCLSCOD="V1" or CRCLSCOD="W" or CRCLSCOD="Y" or CRCLSCOD="Z" or CRCLSCOD="Z1" or CRCLSCOD="Z2" or CRCLSCOD="Z4" or CRCLSCOD="Z5" or CRCLSCOD="ZA" or CRCLSCOD="ZF" or CRCLSCOD="ZY" THEN Bad=1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's not working. It says "Statement is not valid or it is used out of proper order"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Can someone help me please ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 18:08:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Combining-categories-in-SAS/m-p/806118#M39669</guid>
      <dc:creator>beatricedesroch</dc:creator>
      <dc:date>2022-04-05T18:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: Combining categories in SAS</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Combining-categories-in-SAS/m-p/806119#M39670</link>
      <description>&lt;P&gt;You can't use IF statements in PROC FORMAT. The proper syntax is shown &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p1upn25lbfo6mkn1wncu4dyh9q91.htm" target="_blank"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A better approach (maybe):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    length group $ 6;
    if CRCLSCOD=:'A' or CRCLSCOD=:'B' then group='GOOD';
    else if CRCLSCOD=:'C' or CRCLSCOD=:'D' then group='Medium';
    else group='Bad';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 18:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Combining-categories-in-SAS/m-p/806119#M39670</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-05T18:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Combining categories in SAS</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Combining-categories-in-SAS/m-p/806121#M39671</link>
      <description>&lt;P&gt;Alternatively&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value codef 'A','A2','A3','AA','B','B2','BA' ='Good'
             'C','C2','C5','CA','CC','CY','D','D2','D4','D5','DA' ='Medium'
              other='Bad';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Apr 2022 18:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Combining-categories-in-SAS/m-p/806121#M39671</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-05T18:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Combining categories in SAS</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Combining-categories-in-SAS/m-p/806122#M39672</link>
      <description>&lt;P&gt;Define the format.&lt;/P&gt;
&lt;P&gt;Then use it with the variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
value $GMB
 'A','A2','A3','AA','B','B2','BA' = 'Good'
 'C','C2','C5','CA','CC','CY','D','D2','D4','D5','DA' = 'Medium'
 'E','E2','E4','EA','EC','EF','EM','G','GA','GY'
,'H','I','IF','J','JF','K','L','M','O','P1','S'
,'TP','U','U1','V','V1','W','Y','Z','Z1'
,'Z2','Z4','Z5','ZA','ZF','ZY' = 'Bad'
 other = 'Unknown'
;
run;

proc freq data=dm.churn ;
  tables CRCLSCOD ;
  format CRCLSCOD $GMB. ;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Apr 2022 18:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Combining-categories-in-SAS/m-p/806122#M39672</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-05T18:24:13Z</dc:date>
    </item>
  </channel>
</rss>

