<?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 a categorical variable that assigns two different values to some observations? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-that-assigns-two-different/m-p/816683#M322376</link>
    <description>&lt;P&gt;Just run it and see.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=example;
   class age / mlf;
   format age agegroup.;
run;

proc freq data=example;
   tables age / list;
   format age agegroup.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1654535982395.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72015i57A852A94F946D8E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1654535982395.png" alt="Tom_0-1654535982395.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So NO it does not work with PROC FREQ.&lt;/P&gt;</description>
    <pubDate>Mon, 06 Jun 2022 17:20:06 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-06-06T17:20:06Z</dc:date>
    <item>
      <title>Creating a categorical variable that assigns two different values to some observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-that-assigns-two-different/m-p/816664#M322368</link>
      <description>&lt;P&gt;I currently have an age variable with the below categories:&lt;/P&gt;&lt;P&gt;&amp;lt;15,&amp;nbsp;15-17,&amp;nbsp;18-19&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to also create an age group for &lt;STRONG&gt;15-19,&lt;/STRONG&gt; since my frequency tables will ultimately need to be stratified the below groups:&lt;/P&gt;&lt;P&gt;&amp;lt;15, 15-17, 18-19, &lt;STRONG&gt;15-19&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to use a format or data step that will let me double count the observations that are 15-19 as being&amp;nbsp;&lt;EM&gt;both&amp;nbsp;&lt;/EM&gt;15-19&amp;nbsp;&lt;EM&gt;and&amp;nbsp;&lt;/EM&gt;either 15-17 or 18-19? Or does each category in a categorical variable need to be mutually exclusive and assign only 1 value to each observation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 16:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-that-assigns-two-different/m-p/816664#M322368</guid>
      <dc:creator>greesamu</dc:creator>
      <dc:date>2022-06-06T16:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a categorical variable that assigns two different values to some observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-that-assigns-two-different/m-p/816668#M322370</link>
      <description>&lt;P&gt;If you intend to create the summaries with Proc Report, Tabulate or Summary/Means and then Print you can use a MULTILABEL format with the numeric variable containing age.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
    /* make some example data to 
    apply a format
    */
   do age= 13 to 19;
      do i=1 to rand('uniform',6);
         output;
      end;
   end;
   keep age;
run;

proc format;
value agegroup (Multilabel)
low - &amp;lt;15 = '&amp;lt;15'
15 - 19   = '15-19'
15 - 17   = '15-17'
18 - 19   = '18-19'
;

proc means data=example;
   class age / mlf;
   format age agegroup.;
run;

proc tabulate data=example;
   class age /mlf ;
   format age agegroup.;
   table age,
         n pctn
   ;
run;&lt;/PRE&gt;
&lt;P&gt;There are some interesting interactions between the values of the variable, the order the formatted values are assigned and result order in different procedures and some options. So don't hesitate to swap the order of the formatting ranges in the Value statement.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 16:21:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-that-assigns-two-different/m-p/816668#M322370</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-06-06T16:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a categorical variable that assigns two different values to some observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-that-assigns-two-different/m-p/816680#M322374</link>
      <description>&lt;P&gt;Would this option not work with proc freq?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 17:05:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-that-assigns-two-different/m-p/816680#M322374</guid>
      <dc:creator>greesamu</dc:creator>
      <dc:date>2022-06-06T17:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a categorical variable that assigns two different values to some observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-that-assigns-two-different/m-p/816683#M322376</link>
      <description>&lt;P&gt;Just run it and see.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=example;
   class age / mlf;
   format age agegroup.;
run;

proc freq data=example;
   tables age / list;
   format age agegroup.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1654535982395.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72015i57A852A94F946D8E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1654535982395.png" alt="Tom_0-1654535982395.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So NO it does not work with PROC FREQ.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 17:20:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-that-assigns-two-different/m-p/816683#M322376</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-06T17:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a categorical variable that assigns two different values to some observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-that-assigns-two-different/m-p/816770#M322416</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/401848"&gt;@greesamu&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Would this option not work with proc freq?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There was a reason I specifically listed those procedures. If you are looking for basic reporting of counts and percentages then Proc Tabulate generally will do most reporting that Proc Freq does. That is also why I included a Proc Tabulate example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The statistical tests that are possible in Proc Freq are likely a major reason the Multilabel formats aren't implemented there as having the additional overlapping categories would violate one or more requirements for many if not all of the tests implemented.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 21:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-that-assigns-two-different/m-p/816770#M322416</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-06-06T21:25:59Z</dc:date>
    </item>
  </channel>
</rss>

