<?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: Proc Univariate - program ignoring groups in by statement in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Univariate-program-ignoring-groups-in-by-statement/m-p/783863#M81275</link>
    <description>&lt;P&gt;Show your log for the Proc Univariate.&lt;/P&gt;
&lt;P&gt;I bet you have something about a variable named AND in the log. Unless you actually have and mean to use a variable named AND on the By statement.&lt;BR /&gt;I will bet a small stack of $$$ that when you read your LOG that there is an ERROR in your proc univariate code. If you use AND in other procedures likely the same error.&lt;/P&gt;
&lt;PRE&gt;394  proc sort data=sashelp.class out=work.class;
395     by sex age;
396  run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.CLASS has 19 observations and 5 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


397
398  proc univariate data=work.class;
399     by sex and age;
&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;ERROR: Variable AND not found.&lt;/FONT&gt;&lt;/STRONG&gt;
400     var height weight;
401  run;

&lt;/PRE&gt;
&lt;P&gt;If you actually have a variable named AND don't use that keyword on the by unless you mean it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would expect your BY statement to look like:&lt;/P&gt;
&lt;PRE&gt;By gender racecat;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;exactly &lt;/STRONG&gt;the same as the By statement in Proc Sort. You do not use AND on a by statement to include multiple variables.&lt;/P&gt;
&lt;P&gt;And your Univariate code does not include agecat anywhere. Showing an "example" that does not come from your code is not helpful and can be extremely misleading.&lt;/P&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/293653"&gt;@akbarlam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm working on NHANES 2011-2018 complex survey dataset and I've been coding all week, so it's possible I'm just not understanding a potential simple mistake I made. I recoded several variables into categories--for example, race and age. Below is what I coded (this is after concatenating datasets) as an example:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;if race=3 then raceCat=1;
else if race=4 then raceCat=2; 
else if race=6 then raceCat=3;
else if race=1 or race=2 then raceCat=4;
else if race=7 then raceCat=5;&lt;/LI-CODE&gt;
&lt;P&gt;I am now trying to check for normality among some of my variables. I am using PROC UNIVARIATE for this. Below is the code:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc sort; 
by gender racecat; 
run;

PROC UNIVARIATE data=datasetn plot normal;
where age &amp;gt;= 20;
by gender and racecat;    
VAR waistcirc;    
freq wt8yr_ng; *This is the weighting variable;
FORMAT gender SEXFMT.  racecat RACEFMT. ;    
title "Distribution of waist circumference gender and race: NHANES 2011-2018";           
run;&lt;/LI-CODE&gt;
&lt;P&gt;I noticed that in the output, the generated results are not going through all combinations of gender and race categories. For this particular code, only gender 1 (male) and race category 1 (Non-Hispanic White) were generated.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="akbarlam_0-1638518887052.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66368i1886D45707CC22B4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="akbarlam_0-1638518887052.png" alt="akbarlam_0-1638518887052.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;[The screenshot is for the same program, but also includes 'age categories' in the by statement. As you can see, the program is only selecting one age category - 20 to 39 years old and there are no other category combination results after this 1 combo.].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have also noticed the same problem when I ran a simple PROC FREQ procedure cross tabulating with a by statement -- only the first category of the variable in the by statement is used and the rest are ignored. Is there something I need to change in my settings? I'm very confused about why this is occurring.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Dec 2021 09:20:36 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-12-03T09:20:36Z</dc:date>
    <item>
      <title>Proc Univariate - program ignoring groups in by statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Univariate-program-ignoring-groups-in-by-statement/m-p/783856#M81274</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm working on NHANES 2011-2018 complex survey dataset and I've been coding all week, so it's possible I'm just not understanding a potential simple mistake I made. I recoded several variables into categories--for example, race and age. Below is what I coded (this is after concatenating datasets) as an example:&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;if race=3 then raceCat=1;
else if race=4 then raceCat=2; 
else if race=6 then raceCat=3;
else if race=1 or race=2 then raceCat=4;
else if race=7 then raceCat=5;&lt;/LI-CODE&gt;&lt;P&gt;I am now trying to check for normality among some of my variables. I am using PROC UNIVARIATE for this. Below is the code:&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;proc sort; 
by gender racecat; 
run;

PROC UNIVARIATE data=datasetn plot normal;
where age &amp;gt;= 20;
by gender and racecat;    
VAR waistcirc;    
freq wt8yr_ng; *This is the weighting variable;
FORMAT gender SEXFMT.  racecat RACEFMT. ;    
title "Distribution of waist circumference gender and race: NHANES 2011-2018";           
run;&lt;/LI-CODE&gt;&lt;P&gt;I noticed that in the output, the generated results are not going through all combinations of gender and race categories. For this particular code, only gender 1 (male) and race category 1 (Non-Hispanic White) were generated.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="akbarlam_0-1638518887052.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66368i1886D45707CC22B4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="akbarlam_0-1638518887052.png" alt="akbarlam_0-1638518887052.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;[The screenshot is for the same program, but also includes 'age categories' in the by statement. As you can see, the program is only selecting one age category - 20 to 39 years old and there are no other category combination results after this 1 combo.].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also noticed the same problem when I ran a simple PROC FREQ procedure cross tabulating with a by statement -- only the first category of the variable in the by statement is used and the rest are ignored. Is there something I need to change in my settings? I'm very confused about why this is occurring.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 08:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Univariate-program-ignoring-groups-in-by-statement/m-p/783856#M81274</guid>
      <dc:creator>akbarlam</dc:creator>
      <dc:date>2021-12-03T08:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Univariate - program ignoring groups in by statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Univariate-program-ignoring-groups-in-by-statement/m-p/783863#M81275</link>
      <description>&lt;P&gt;Show your log for the Proc Univariate.&lt;/P&gt;
&lt;P&gt;I bet you have something about a variable named AND in the log. Unless you actually have and mean to use a variable named AND on the By statement.&lt;BR /&gt;I will bet a small stack of $$$ that when you read your LOG that there is an ERROR in your proc univariate code. If you use AND in other procedures likely the same error.&lt;/P&gt;
&lt;PRE&gt;394  proc sort data=sashelp.class out=work.class;
395     by sex age;
396  run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.CLASS has 19 observations and 5 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


397
398  proc univariate data=work.class;
399     by sex and age;
&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;ERROR: Variable AND not found.&lt;/FONT&gt;&lt;/STRONG&gt;
400     var height weight;
401  run;

&lt;/PRE&gt;
&lt;P&gt;If you actually have a variable named AND don't use that keyword on the by unless you mean it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would expect your BY statement to look like:&lt;/P&gt;
&lt;PRE&gt;By gender racecat;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;exactly &lt;/STRONG&gt;the same as the By statement in Proc Sort. You do not use AND on a by statement to include multiple variables.&lt;/P&gt;
&lt;P&gt;And your Univariate code does not include agecat anywhere. Showing an "example" that does not come from your code is not helpful and can be extremely misleading.&lt;/P&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/293653"&gt;@akbarlam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm working on NHANES 2011-2018 complex survey dataset and I've been coding all week, so it's possible I'm just not understanding a potential simple mistake I made. I recoded several variables into categories--for example, race and age. Below is what I coded (this is after concatenating datasets) as an example:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;if race=3 then raceCat=1;
else if race=4 then raceCat=2; 
else if race=6 then raceCat=3;
else if race=1 or race=2 then raceCat=4;
else if race=7 then raceCat=5;&lt;/LI-CODE&gt;
&lt;P&gt;I am now trying to check for normality among some of my variables. I am using PROC UNIVARIATE for this. Below is the code:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc sort; 
by gender racecat; 
run;

PROC UNIVARIATE data=datasetn plot normal;
where age &amp;gt;= 20;
by gender and racecat;    
VAR waistcirc;    
freq wt8yr_ng; *This is the weighting variable;
FORMAT gender SEXFMT.  racecat RACEFMT. ;    
title "Distribution of waist circumference gender and race: NHANES 2011-2018";           
run;&lt;/LI-CODE&gt;
&lt;P&gt;I noticed that in the output, the generated results are not going through all combinations of gender and race categories. For this particular code, only gender 1 (male) and race category 1 (Non-Hispanic White) were generated.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="akbarlam_0-1638518887052.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66368i1886D45707CC22B4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="akbarlam_0-1638518887052.png" alt="akbarlam_0-1638518887052.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;[The screenshot is for the same program, but also includes 'age categories' in the by statement. As you can see, the program is only selecting one age category - 20 to 39 years old and there are no other category combination results after this 1 combo.].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have also noticed the same problem when I ran a simple PROC FREQ procedure cross tabulating with a by statement -- only the first category of the variable in the by statement is used and the rest are ignored. Is there something I need to change in my settings? I'm very confused about why this is occurring.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 09:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Univariate-program-ignoring-groups-in-by-statement/m-p/783863#M81275</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-03T09:20:36Z</dc:date>
    </item>
  </channel>
</rss>

