<?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 Subsetting datasets in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting-datasets/m-p/438175#M69054</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having some issues subsetting my dataset. My goal is to create two new datasets (mn2 and mn3) from an original dataset. I want mn2 to contain observations that have no missing values in any of these variables:&lt;/P&gt;&lt;P&gt;hair_mn_ppm&lt;/P&gt;&lt;P&gt;ied_eds_err&lt;/P&gt;&lt;P&gt;ied_preed_err&lt;/P&gt;&lt;P&gt;ied_total_err&lt;/P&gt;&lt;P&gt;wm_comprverbal_w&lt;/P&gt;&lt;P&gt;wm_apprendvisaud_w&lt;/P&gt;&lt;P&gt;wm_relespatial_w&lt;/P&gt;&lt;P&gt;wm_formconcept_w&lt;/P&gt;&lt;P&gt;wm_pareovis_w&lt;/P&gt;&lt;P&gt;wm_inversenum_w&lt;/P&gt;&lt;P&gt;ci_woodcock&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I would like mn3 to contain all that were excluded from mn2. I need to retain both sets of these data because I will need to later report how they differ from one another. Would it be easier just to code new variables all within the original dataset? Am I making my life too hard?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code I've used so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mn2 mn3;
set mn1;
if hair_mn_ppm=. AND ied_eds_err = .
AND ied_preed_err =.
AND ied_total_err =.
AND wm_comprverbal_w =.
AND wm_apprendvisaud_w =.
AND wm_relespatial_w =.
AND wm_formconcept_w =.
AND wm_pareovis_w =.
AND wm_inversenum_w =.
AND ci_woodcock =. THEN OUTPUT mn2;
ELSE OUTPUT mn3;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 17 Feb 2018 18:03:36 GMT</pubDate>
    <dc:creator>TMSmith</dc:creator>
    <dc:date>2018-02-17T18:03:36Z</dc:date>
    <item>
      <title>Subsetting datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting-datasets/m-p/438175#M69054</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having some issues subsetting my dataset. My goal is to create two new datasets (mn2 and mn3) from an original dataset. I want mn2 to contain observations that have no missing values in any of these variables:&lt;/P&gt;&lt;P&gt;hair_mn_ppm&lt;/P&gt;&lt;P&gt;ied_eds_err&lt;/P&gt;&lt;P&gt;ied_preed_err&lt;/P&gt;&lt;P&gt;ied_total_err&lt;/P&gt;&lt;P&gt;wm_comprverbal_w&lt;/P&gt;&lt;P&gt;wm_apprendvisaud_w&lt;/P&gt;&lt;P&gt;wm_relespatial_w&lt;/P&gt;&lt;P&gt;wm_formconcept_w&lt;/P&gt;&lt;P&gt;wm_pareovis_w&lt;/P&gt;&lt;P&gt;wm_inversenum_w&lt;/P&gt;&lt;P&gt;ci_woodcock&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I would like mn3 to contain all that were excluded from mn2. I need to retain both sets of these data because I will need to later report how they differ from one another. Would it be easier just to code new variables all within the original dataset? Am I making my life too hard?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code I've used so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mn2 mn3;
set mn1;
if hair_mn_ppm=. AND ied_eds_err = .
AND ied_preed_err =.
AND ied_total_err =.
AND wm_comprverbal_w =.
AND wm_apprendvisaud_w =.
AND wm_relespatial_w =.
AND wm_formconcept_w =.
AND wm_pareovis_w =.
AND wm_inversenum_w =.
AND ci_woodcock =. THEN OUTPUT mn2;
ELSE OUTPUT mn3;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Feb 2018 18:03:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting-datasets/m-p/438175#M69054</guid>
      <dc:creator>TMSmith</dc:creator>
      <dc:date>2018-02-17T18:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting-datasets/m-p/438181#M69055</link>
      <description>&lt;P&gt;&amp;nbsp;you need to use "or"&amp;nbsp; instead of "and" an example below. And looks for all or looks for any condition&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
input xyz yxs zzz uuu;
datalines;
1 2 3 7
2 3 4 6
. . . 7
. 8 2 4
6 7 . 6
. 9 . 7
;

data abcd abcde;
set abc;
if (xyz = .) or (yxs = .) or (zzz = .) then output abcde;
else output abcd;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2018 19:45:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting-datasets/m-p/438181#M69055</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-02-17T19:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting-datasets/m-p/438184#M69056</link>
      <description>&lt;P&gt;Got it. For the sake of those (like myself) who may struggle in the future:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*getting n with exclusions*/
	/*hair*/
data mn2;
set mn1;
if nmiss (hair_mn_ppm, ied_eds_err, ied_preed_err, ied_total_err,wm_comprverbal_w,
wm_apprendvisaud_w, wm_relespacial_w, wm_formconcept_w, wm_pareovis_w, wm_inversnum_w,
ci_woodcock) =0; run;
proc print noobs; run;
	/*water*/

data mn3;
set mn1;
if nmiss (water_mn_ppm, ied_eds_err, ied_preed_err, ied_total_err,wm_comprverbal_w,
wm_apprendvisaud_w, wm_relespacial_w, wm_formconcept_w, wm_pareovis_w, wm_inversnum_w,
ci_woodcock) =0; run;
proc print noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Best source of help:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2015/02/23/complete-cases.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2015/02/23/complete-cases.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2018 19:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting-datasets/m-p/438184#M69056</guid>
      <dc:creator>TMSmith</dc:creator>
      <dc:date>2018-02-17T19:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting-datasets/m-p/438190#M69057</link>
      <description>&lt;P&gt;Oh, wow. That was such a silly mistake of mine. Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2018 20:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting-datasets/m-p/438190#M69057</guid>
      <dc:creator>TMSmith</dc:creator>
      <dc:date>2018-02-17T20:14:55Z</dc:date>
    </item>
  </channel>
</rss>

