<?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: Using where statement in proc freq in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811128#M319932</link>
    <description>&lt;P&gt;Always beware of the "hidden blanks" used to patch up the unused space in character variables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where strip(birth) in ("Yes","No");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And make sure you get your spelling absolutely right. "Yes" ^= "yes"!&lt;/P&gt;</description>
    <pubDate>Mon, 02 May 2022 19:37:08 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-05-02T19:37:08Z</dc:date>
    <item>
      <title>Using where statement in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811125#M319929</link>
      <description>&lt;P&gt;Hi programmers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to test for association of 2 variables using the proc freq procedure for a predictor that has 4 levels against an outcome that has 5 categories.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I specifically want to select 2 levels of the predictor and not use all 4 in this test. I have tried the "where" statement but i haven't gotten any success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I like to know where the issue could come from.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc freq data = A;
tables group*birth
/chisq cmh;
where birth = ('Yes'  'No');
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 19:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811125#M319929</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2022-05-02T19:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using where statement in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811126#M319930</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where birth in ("Yes" "No");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 May 2022 19:26:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811126#M319930</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-02T19:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using where statement in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811127#M319931</link>
      <description>Hi I did that and it's telling me that there were zero observations read from the dataset.</description>
      <pubDate>Mon, 02 May 2022 19:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811127#M319931</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2022-05-02T19:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using where statement in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811128#M319932</link>
      <description>&lt;P&gt;Always beware of the "hidden blanks" used to patch up the unused space in character variables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where strip(birth) in ("Yes","No");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And make sure you get your spelling absolutely right. "Yes" ^= "yes"!&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 19:37:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811128#M319932</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-05-02T19:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using where statement in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811129#M319933</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236266"&gt;@ChuksManuel&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi I did that and it's telling me that there were zero observations read from the dataset.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In addition to what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;said, you need to look at the data set with your own eyes to see why "Yes" is not found in the data set, and why "No" is not found in the data set. It is possible that your variable BIRTH is formatted and so the actual values are 0 or 1 (or some other values).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can look at the unformatted values by running PROC FREQ again without the WHERE statement and adding in&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format birth;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which removes the formatting from the variable, or in whatever data set viewer you use you can also indicate that you want to remove the format from BIRTH.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But here we get into the problem that you are getting incorrect results, and you have not shown us the LOG, which would be extremely helpful, and should be something you show us every single time there are problems identified in the LOG. That's&amp;nbsp;&lt;STRONG&gt;EVERY SINGLE TIME&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 19:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811129#M319933</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-02T19:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using where statement in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811130#M319934</link>
      <description>Yes. Formatting was the reason.</description>
      <pubDate>Mon, 02 May 2022 19:56:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811130#M319934</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2022-05-02T19:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using where statement in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811131#M319935</link>
      <description>&lt;P&gt;You need IN operator not equality operator to select multiple values.&lt;/P&gt;
&lt;P&gt;The values have be the actual values of the variable, not the formatted values.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For character variables the value has to match exactly.&amp;nbsp; Case matters.&amp;nbsp;Trailing spaces don't matter, but leading spaces do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where lowcase(left(birth)) in ('yes'  'no');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the variable is actually numeric with a format that displays two (or more) of the values as Yes and No then you need to use the actual numeric values in your list of values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where birth in (0 1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or perhaps use the format in the WHERE statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where put(birth,birthfmt.) in ('Yes' 'No');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 May 2022 19:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-where-statement-in-proc-freq/m-p/811131#M319935</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-02T19:59:08Z</dc:date>
    </item>
  </channel>
</rss>

