<?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 how to give 'where' condition twice in a one code set in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-to-give-where-condition-twice-in-a-one-code-set/m-p/33631#M8141</link>
    <description>Hi Colleagues,&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I have a 10,703 observation size dataset like this.&lt;BR /&gt;
&lt;BR /&gt;
data HH;&lt;BR /&gt;
input pumfid PEFAMTYP_M   deprived  MD_Q02  MD_Q06  MD_Q14	WTFM;&lt;BR /&gt;
cards;&lt;BR /&gt;
&lt;BR /&gt;
1	1	2	1	2	2	1&lt;BR /&gt;
2	7	1	2	1	6	1&lt;BR /&gt;
3	7	2	6	6	1	1&lt;BR /&gt;
4	7	2	7	1	7	1&lt;BR /&gt;
5	1	2	1	7	9	1&lt;BR /&gt;
6	1	2	1	9	9	1&lt;BR /&gt;
7	7	1	1	1	7	1&lt;BR /&gt;
8	1	2	6	1	2	1&lt;BR /&gt;
9	7	2	7	1	1	1&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I need to find the count of families with all the following conditions.&lt;BR /&gt;
1. who are deprived (i.e. deprived =1) &lt;BR /&gt;
2. only family type 7 (i.e. PEFAMTYP_M = 7)&lt;BR /&gt;
3. any one of MD_Q02 or MD_Q06 or MD_Q14 should have the code 1&lt;BR /&gt;
&lt;BR /&gt;
I gave the following command but produce some strange frequency table.&lt;BR /&gt;
&lt;BR /&gt;
proc surveyfreq data=HH;&lt;BR /&gt;
tables pumfid;&lt;BR /&gt;
WEIGHT WTFM;&lt;BR /&gt;
where deprived =1 and PEFAMTYP_M=7; &lt;BR /&gt;
where MD_Q02=1 or MD_Q06=1 or MD_Q14=1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The answer should be ID numbers 2 and 7 because they satisfy the all above conditions.&lt;BR /&gt;
&lt;BR /&gt;
Appreciate if anyone could help. You can just ignore surveyfreq and wieghts what I need is to learn how to give conditions accurately.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Mirisage</description>
    <pubDate>Wed, 09 Jun 2010 22:17:16 GMT</pubDate>
    <dc:creator>Mirisage</dc:creator>
    <dc:date>2010-06-09T22:17:16Z</dc:date>
    <item>
      <title>how to give 'where' condition twice in a one code set</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-give-where-condition-twice-in-a-one-code-set/m-p/33631#M8141</link>
      <description>Hi Colleagues,&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I have a 10,703 observation size dataset like this.&lt;BR /&gt;
&lt;BR /&gt;
data HH;&lt;BR /&gt;
input pumfid PEFAMTYP_M   deprived  MD_Q02  MD_Q06  MD_Q14	WTFM;&lt;BR /&gt;
cards;&lt;BR /&gt;
&lt;BR /&gt;
1	1	2	1	2	2	1&lt;BR /&gt;
2	7	1	2	1	6	1&lt;BR /&gt;
3	7	2	6	6	1	1&lt;BR /&gt;
4	7	2	7	1	7	1&lt;BR /&gt;
5	1	2	1	7	9	1&lt;BR /&gt;
6	1	2	1	9	9	1&lt;BR /&gt;
7	7	1	1	1	7	1&lt;BR /&gt;
8	1	2	6	1	2	1&lt;BR /&gt;
9	7	2	7	1	1	1&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I need to find the count of families with all the following conditions.&lt;BR /&gt;
1. who are deprived (i.e. deprived =1) &lt;BR /&gt;
2. only family type 7 (i.e. PEFAMTYP_M = 7)&lt;BR /&gt;
3. any one of MD_Q02 or MD_Q06 or MD_Q14 should have the code 1&lt;BR /&gt;
&lt;BR /&gt;
I gave the following command but produce some strange frequency table.&lt;BR /&gt;
&lt;BR /&gt;
proc surveyfreq data=HH;&lt;BR /&gt;
tables pumfid;&lt;BR /&gt;
WEIGHT WTFM;&lt;BR /&gt;
where deprived =1 and PEFAMTYP_M=7; &lt;BR /&gt;
where MD_Q02=1 or MD_Q06=1 or MD_Q14=1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The answer should be ID numbers 2 and 7 because they satisfy the all above conditions.&lt;BR /&gt;
&lt;BR /&gt;
Appreciate if anyone could help. You can just ignore surveyfreq and wieghts what I need is to learn how to give conditions accurately.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Mirisage</description>
      <pubDate>Wed, 09 Jun 2010 22:17:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-give-where-condition-twice-in-a-one-code-set/m-p/33631#M8141</guid>
      <dc:creator>Mirisage</dc:creator>
      <dc:date>2010-06-09T22:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to give 'where' condition twice in a one code set</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-give-where-condition-twice-in-a-one-code-set/m-p/33632#M8142</link>
      <description>Firstly with two WHERE statements, the last one will supercede the previous one so that one is the only active one. &lt;BR /&gt;
&lt;BR /&gt;
If you want both to work, which your conditions confirm, then you need to change your second WHERE to WHERE ALSO. Alternatively you can combine the two into one like so:&lt;BR /&gt;
&lt;BR /&gt;
 where deprived =1 and PEFAMTYP_M=7 &lt;BR /&gt;
  and (MD_Q02=1 or MD_Q06=1 or MD_Q14=1);</description>
      <pubDate>Thu, 10 Jun 2010 01:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-give-where-condition-twice-in-a-one-code-set/m-p/33632#M8142</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2010-06-10T01:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to give 'where' condition twice in a one code set</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-give-where-condition-twice-in-a-one-code-set/m-p/33633#M8143</link>
      <description>Hi:&lt;BR /&gt;
  Just using PROC PRINT (since I don't know PROC SURVEYFREQ), both of these methods work for me. I find that I prefer the use of parentheses and logical operators over the use of WHERE ALSO, but in this instance they both produce the same results.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
proc print data=HH;&lt;BR /&gt;
title 'Method 1';&lt;BR /&gt;
where (deprived =1 and PEFAMTYP_M=7)&lt;BR /&gt;
      and&lt;BR /&gt;
      (MD_Q02=1 or MD_Q06=1 or MD_Q14=1);&lt;BR /&gt;
run;&lt;BR /&gt;
                            &lt;BR /&gt;
proc print data=HH;&lt;BR /&gt;
title 'Method 2';&lt;BR /&gt;
where deprived =1 and PEFAMTYP_M=7;&lt;BR /&gt;
where also MD_Q02=1 or MD_Q06=1 or MD_Q14=1;&lt;BR /&gt;
run;&lt;BR /&gt;
                             &lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 10 Jun 2010 01:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-give-where-condition-twice-in-a-one-code-set/m-p/33633#M8143</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-06-10T01:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to give 'where' condition twice in a one code set</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-give-where-condition-twice-in-a-one-code-set/m-p/33634#M8144</link>
      <description>Hi SASKiwi and Cynthia,&lt;BR /&gt;
&lt;BR /&gt;
This is great!&lt;BR /&gt;
&lt;BR /&gt;
All the codes provided by both of you worked elegantly and thank you very much.&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
&lt;BR /&gt;
Mirisage</description>
      <pubDate>Thu, 10 Jun 2010 02:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-give-where-condition-twice-in-a-one-code-set/m-p/33634#M8144</guid>
      <dc:creator>Mirisage</dc:creator>
      <dc:date>2010-06-10T02:38:22Z</dc:date>
    </item>
  </channel>
</rss>

