<?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: Grouping results in variables in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Grouping-results-in-variables/m-p/603047#M8258</link>
    <description>&lt;P&gt;class needs no sorting, but you should try to create a format that converts your days into categories and use that for the class variable.&lt;/P&gt;</description>
    <pubDate>Sun, 10 Nov 2019 09:29:17 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-11-10T09:29:17Z</dc:date>
    <item>
      <title>Grouping results in variables</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Grouping-results-in-variables/m-p/603046#M8257</link>
      <description>&lt;P&gt;Hello!&amp;nbsp; I am trying to perform a one way ANOVA comparison of merged data.&amp;nbsp; I have been able to merge the data, but I am having trouble with combining some variable data.&amp;nbsp; I am wanting to look at the variable of age (RIDAGEYR) with the variable of days of physical activity per week (PAQ670) .&amp;nbsp; For my project, I would like to group the days into 3 categories (1-2 days, 3-5 days, 6-7 days) and run a ANOVA test to get the mean age for each of the three categories.&amp;nbsp; I have been able to run the ANOVA, but not able to separate the wanted categories.&amp;nbsp; Here is my code and output--&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work. agephysicalhealth;&lt;BR /&gt;merge SASFILE.DEMO_H SASFILE.PAQ_H;&lt;BR /&gt;by SEQN;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc anova data=WORK.AGEPHYSICALHEALTH;&lt;BR /&gt;class PAQ670;&lt;BR /&gt;model RIDAGEYR = PAQ670;&lt;BR /&gt;means PAQ670 / scheffe;&lt;BR /&gt;title;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output lists the *class PAQ670 and values 1 2 3 4 5 6 7 99*&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not figured out how to separate these - not sure if I should sort the data prior to running the procedure or sort after.&amp;nbsp; I would like to use the same code for all of my procedures because I am running multiple analysis on the variable of days of physical activity.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for any help!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Carrie&lt;/P&gt;</description>
      <pubDate>Sun, 10 Nov 2019 07:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Grouping-results-in-variables/m-p/603046#M8257</guid>
      <dc:creator>Monaghan</dc:creator>
      <dc:date>2019-11-10T07:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping results in variables</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Grouping-results-in-variables/m-p/603047#M8258</link>
      <description>&lt;P&gt;class needs no sorting, but you should try to create a format that converts your days into categories and use that for the class variable.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Nov 2019 09:29:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Grouping-results-in-variables/m-p/603047#M8258</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-10T09:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping results in variables</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Grouping-results-in-variables/m-p/603078#M8259</link>
      <description>&lt;P&gt;Here's an example of how you can create a format and apply it. You can run the code and examine the output, it should work in any version of SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*this is an example of creating a custom format and then applying it to a data set*/

*create the format;
proc format;
value age_group
low - 13 = 'Pre-Teen'
13 - 15 = 'Teen'
16 - high = 'Adult';
run;

title 'Example of an applied format';
proc print data=sashelp.class;
format age age_group.; *applies the format;
run;


data class;
set sashelp.class;
age_category = put(age, age_group.); *creates a character variable with the age category;
label age_category = 'Age Category'; *adds a nice label for the printed output;
run;

title 'Example of creating a new variable with the format';
proc print data=class label;
run;

*show format used directly;

proc freq data=sashelp.class;
table age / out= formatted_age;
format age age_group.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For your specific group your format would look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value days_category
1-2 = "1 to 2 days"
3-5 = "3 to 5 days"
6-7 = "6 to 7 days"
99 = "Missing";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then apply it in your code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc anova data=WORK.AGEPHYSICALHEALTH;
class PAQ670;
format paq670 days_category.;

model RIDAGEYR = PAQ670;
means PAQ670 / scheffe;

title;
run;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/297985"&gt;@Monaghan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello!&amp;nbsp; I am trying to perform a one way ANOVA comparison of merged data.&amp;nbsp; I have been able to merge the data, but I am having trouble with combining some variable data.&amp;nbsp; I am wanting to look at the variable of age (RIDAGEYR) with the variable of days of physical activity per week (PAQ670) .&amp;nbsp; For my project, I would like to group the days into 3 categories (1-2 days, 3-5 days, 6-7 days) and run a ANOVA test to get the mean age for each of the three categories.&amp;nbsp; I have been able to run the ANOVA, but not able to separate the wanted categories.&amp;nbsp; Here is my code and output--&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data work. agephysicalhealth;&lt;BR /&gt;merge SASFILE.DEMO_H SASFILE.PAQ_H;&lt;BR /&gt;by SEQN;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc anova data=WORK.AGEPHYSICALHEALTH;&lt;BR /&gt;class PAQ670;&lt;BR /&gt;model RIDAGEYR = PAQ670;&lt;BR /&gt;means PAQ670 / scheffe;&lt;BR /&gt;title;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output lists the *class PAQ670 and values 1 2 3 4 5 6 7 99*&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have not figured out how to separate these - not sure if I should sort the data prior to running the procedure or sort after.&amp;nbsp; I would like to use the same code for all of my procedures because I am running multiple analysis on the variable of days of physical activity.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for any help!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Carrie&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Nov 2019 21:21:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Grouping-results-in-variables/m-p/603078#M8259</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-10T21:21:06Z</dc:date>
    </item>
  </channel>
</rss>

