<?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: Subsetting in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99973#M28053</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That was very detailed. ...&lt;/P&gt;&lt;P&gt;I understood the concept well after that explanation......One last Question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; font-size: 10pt; font-family: Courier New;"&gt;IST DO LOOP&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;n_missing=1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; ID=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;101&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; cat=in2 value=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _ERROR_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _N_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;n_missing=&lt;/STRONG&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; ID=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;101&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; cat=out2 value=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _ERROR_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _N_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;2&amp;nbsp; &amp;lt;&amp;lt;&amp;lt;-----how does SAS know that it has to put &lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;n_missing of this record (from top loop) to "both" the records of the bottom loop from the second SET stmnt??????&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;IIND DO LOOP&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;n_missing=&lt;/STRONG&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; ID=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;101&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; cat=in2 value=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _ERROR_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _N_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;n_missing=&lt;/STRONG&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; ID=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;101&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; cat=out2 value=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _ERROR_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _N_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;Thnks&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Jun 2013 13:14:12 GMT</pubDate>
    <dc:creator>robertrao</dc:creator>
    <dc:date>2013-06-18T13:14:12Z</dc:date>
    <item>
      <title>Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99958#M28038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;in1 out1 is a pair likewise is in2 out2&lt;/P&gt;&lt;P&gt;when both the values of the pair are missing then i want to delete those records....&lt;/P&gt;&lt;P&gt;when a&amp;nbsp; single value is absent of the pair i want to keep those records intact&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HAVE&lt;BR /&gt; &lt;STRONG&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cat&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/P&gt;&lt;P&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 60&lt;/P&gt;&lt;P&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;&amp;nbsp; .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt; .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/P&gt;&lt;P&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 69&lt;/P&gt;&lt;P&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp; out2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt; .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp; in1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp; out1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;104&amp;nbsp;&amp;nbsp; in1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;104&amp;nbsp;&amp;nbsp; out1&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;104&amp;nbsp;&amp;nbsp; in2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;104&amp;nbsp;&amp;nbsp; out2&amp;nbsp;&amp;nbsp; .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WANT&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cat&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value&lt;/P&gt;&lt;P&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/P&gt;&lt;P&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 60&lt;/P&gt;&lt;P&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/P&gt;&lt;P&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 69&lt;/P&gt;&lt;P&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp; out2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt; .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp; in1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp; out1&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt; .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;104&amp;nbsp;&amp;nbsp; in1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;104&amp;nbsp;&amp;nbsp; out1&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 17:24:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99958#M28038</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-06-07T17:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99959#M28039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe you can do a lag of value based on id and then delete that observation if both are missing on a row?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 17:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99959#M28039</guid>
      <dc:creator>caveman529</dc:creator>
      <dc:date>2013-06-07T17:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99960#M28040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data answer1;&lt;/P&gt;&lt;P&gt;set yourdata;&lt;/P&gt;&lt;P&gt;order=input(substr(reverse(strip(cat)),1,1),7.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table answer2 as&lt;/P&gt;&lt;P&gt;select sum(case when value is null then 1 else 0 end) as missing&lt;/P&gt;&lt;P&gt;,id&lt;/P&gt;&lt;P&gt;,order&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from answer1&lt;/P&gt;&lt;P&gt;group by id&lt;/P&gt;&lt;P&gt;,order;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table FinalAnswer as&lt;/P&gt;&lt;P&gt;select a1.id&lt;/P&gt;&lt;P&gt;,a1.cat&lt;/P&gt;&lt;P&gt;,a1.value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from answer1 a1&lt;/P&gt;&lt;P&gt;left join answer12 a12 on a1.id=a12.id and a1.order=a12.order&lt;/P&gt;&lt;P&gt;where a12.missing~=2;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Notice this only works if you variables comes in groups of 2 and have numerics at the end of their variables (aka your example). However this type of code can be made far more generic pretty easily.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 18:33:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99960#M28040</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2013-06-07T18:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99961#M28041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This version should work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; n_missing=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _n_=1 to 2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if value=. then n_missing + 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _n_=1 to 2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if n_missing &amp;lt; 2 then output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; drop n_missing;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One of the keys here is that each SET statement operates independently of the other.&amp;nbsp; Each starts with the first observation, and reads the next observation whenever it executes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program does rely on the structure to the data being accurate.&amp;nbsp; It doesn't even look at CAT.&amp;nbsp; It just assumes that each pair of observations are a matching group that should either both remain or both be deleted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 18:35:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99961#M28041</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-06-07T18:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99962#M28042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or create a sub category variable and use a simple proc SQL:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ID $&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cat$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in1 30&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out1 60&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in1 20&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out1 30&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in2 69&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp; out2 .&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp; in1 20&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp; out1 .&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;104&amp;nbsp;&amp;nbsp; in1 10&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;104&amp;nbsp;&amp;nbsp; out1 .&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;104&amp;nbsp;&amp;nbsp; in2 .&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;104&amp;nbsp;&amp;nbsp; out2 .&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; want &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; *, compress(cat,,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'kd'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; _cat &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; have &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;group&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; id, _cat&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; having &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;not&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; missing(sum(value));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;Haikuo &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 18:38:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99962#M28042</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-06-07T18:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99963#M28043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;I tried the datastep since i am a beginner and it seems to be like how I intend.&lt;/P&gt;&lt;P&gt;I dint understand your code fully..&lt;/P&gt;&lt;P&gt;Could you please explain to me...?????&lt;/P&gt;&lt;P&gt;I dont underastand why we are getting a n_missing of 2 when the value is missing??? etc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 18:55:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99963#M28043</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-06-07T18:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99964#M28044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The top DO loop reads two observations (notice the loop has _N_=1 TO 2).&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before that loop starts, N_MISSING=0.&amp;nbsp; Inside the loop, N_MISSING gets increased each time a missing value is found.&amp;nbsp; So when the top loop ends, N_MISSING=2 whenever both observations had a missing value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At that point, the heavy lifting is over.&amp;nbsp; The bottom DO loop reads the same observations, and outputs them when fewer than 2 missing values were found.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 19:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99964#M28044</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-06-07T19:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99965#M28045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data card;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input id cat $ value;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp; in1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/P&gt;&lt;P&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp; out1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 60&lt;/P&gt;&lt;P&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp; in2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;101&amp;nbsp;&amp;nbsp;&amp;nbsp; out2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp; in1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp; out1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/P&gt;&lt;P&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp; in2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 69&lt;/P&gt;&lt;P&gt;102&amp;nbsp;&amp;nbsp;&amp;nbsp; out2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp; in1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20 &lt;/P&gt;&lt;P&gt;103&amp;nbsp;&amp;nbsp;&amp;nbsp; out1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; . &lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print ; run ; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data = card ; by id&amp;nbsp; value ; run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data card_nodups&amp;nbsp; dups ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set card ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by id&amp;nbsp; value ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.value and last.value then output card_nodups ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else output dups ;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;proc print card_nodups&amp;nbsp; ; run ; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 20:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99965#M28045</guid>
      <dc:creator>devnand</dc:creator>
      <dc:date>2013-06-07T20:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99966#M28046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I hope this will help ..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 20:22:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99966#M28046</guid>
      <dc:creator>devnand</dc:creator>
      <dc:date>2013-06-07T20:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99967#M28047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H1&gt;I posted this question,&lt;/H1&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 18pt;"&gt;&lt;A _jive_internal="true" href="https://communities.sas.com/message/170304#170304"&gt;How to perform ANOVA and multiple comparisons with PROC surveymeans?&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 18pt;"&gt;This question is Not Answered.&lt;A _jive_internal="true" href="https://communities.sas.com/message/170304#170304"&gt;(Mark as assumed answered)&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 18pt;"&gt;but no answers available yet. I am not sure if I posted it correcetly. Could you please let me know because this is my first experience.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 20:44:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99967#M28047</guid>
      <dc:creator>sstoline</dc:creator>
      <dc:date>2013-06-07T20:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99968#M28048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;How is that if i run the Upper DO&amp;nbsp; loop alone it outputs only the second record of the pair????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 20:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99968#M28048</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-06-17T20:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99969#M28049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That result seems perfectly normal.&amp;nbsp; To execute a DATA step, SAS performs all the statements in the DATA step and then outputs whatever the results are.&amp;nbsp; So the top DO loop reads two observations, and then when the DATA statements are complete, the results contain the contents of the second observation.&amp;nbsp; That gets output.&amp;nbsp; Then the process repeats.&amp;nbsp; Execute the top DO loop again, and get the next two observations.&amp;nbsp; When that is complete, the results contain the contents of the fourth observation, so output that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good to see that you are trying test programs to get a sense of how SAS will handle different situations.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 20:40:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99969#M28049</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-06-17T20:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99970#M28050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That was quick!!!!!&lt;/P&gt;&lt;P&gt;So after the first loop we have only the last record of the pair and the corresponding n_missing value.A total of 7 records for our example&lt;/P&gt;&lt;P&gt;The seond Do loop takes the 14 records again fresh(ignoring what the first loop has ). and &lt;STRONG&gt;how does it get to know the n_missing value for the forst record of the pair&lt;/STRONG&gt;????.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a ton&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 20:52:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99970#M28050</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-06-17T20:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99971#M28051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you have the order a little mixed up here.&amp;nbsp; When the first loop is over, you do not have 7 observations.&amp;nbsp; Eventually, by the end of the DATA step, you will have run through the first loop 7 times.&amp;nbsp; But the first loop executes once, reading the first two observations.&amp;nbsp; Then the second loop executes, reading the same two observations.&amp;nbsp; So the value of N_MISSING (based on the first two observations) just sits there and is available to the second loop.&amp;nbsp; After the second loop finishes, the DATA step continues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once again, the first loop reads two observations (observations 3 and 4).&amp;nbsp; Then the second loop reads the same observations. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It may help to examine a simpler DATA step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set old;&lt;/P&gt;&lt;P&gt;name='Fred';&lt;/P&gt;&lt;P&gt;x=5;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The SET statement executes many times here.&amp;nbsp; The first time, it reads the first observation from OLD.&amp;nbsp; For that first observation, NAME= executes, then X= executes.&amp;nbsp; Whatever is left gets output and becomes the first observation in NEW.&amp;nbsp; Then the DATA step continues.&amp;nbsp; The SET statement executes again, reading the second observation from OLD.&amp;nbsp; Then NAME= executes, X= executes, and the result gets output.&amp;nbsp; So the SET statement reads a single observation at a time, starting at the beginning of the incoming data set, and executes as many times as needed (yes, there are more details to that part).&amp;nbsp; If there are multiple SET statements (as in the original problem), each one operates independently of the other (each starts by reading the first observation, and continues wherever it left off).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 21:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99971#M28051</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-06-17T21:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99972#M28052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or DOW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data have;
input ID $&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cat$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value;
cards;
101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in1 30
101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out1 60
101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .
101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .
102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in1 20
102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out1 30
102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in2 69
102&amp;nbsp;&amp;nbsp;&amp;nbsp; out2 .
103&amp;nbsp;&amp;nbsp;&amp;nbsp; in1 20
103&amp;nbsp;&amp;nbsp;&amp;nbsp; out1 .
104&amp;nbsp;&amp;nbsp; in1 10
104&amp;nbsp;&amp;nbsp; out1 .
104&amp;nbsp;&amp;nbsp; in2 .
104&amp;nbsp;&amp;nbsp; out2 .
;

data want;
n=0;
 do until(cat eq: 'out');
&amp;nbsp; set have;
&amp;nbsp; if missing(value) then n+1;
 end;
 do until(cat eq: 'out');
&amp;nbsp; set have;
&amp;nbsp; if&amp;nbsp; n ne 2 then output;
 end;
 run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jun 2013 09:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99972#M28052</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2013-06-18T09:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99973#M28053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That was very detailed. ...&lt;/P&gt;&lt;P&gt;I understood the concept well after that explanation......One last Question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; font-size: 10pt; font-family: Courier New;"&gt;IST DO LOOP&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;n_missing=1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; ID=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;101&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; cat=in2 value=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _ERROR_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _N_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;n_missing=&lt;/STRONG&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; ID=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;101&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; cat=out2 value=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _ERROR_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _N_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;2&amp;nbsp; &amp;lt;&amp;lt;&amp;lt;-----how does SAS know that it has to put &lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;n_missing of this record (from top loop) to "both" the records of the bottom loop from the second SET stmnt??????&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;IIND DO LOOP&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;n_missing=&lt;/STRONG&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; ID=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;101&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; cat=in2 value=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _ERROR_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _N_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;n_missing=&lt;/STRONG&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; ID=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;101&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; cat=out2 value=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _ERROR_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _N_=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;Thnks&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jun 2013 13:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99973#M28053</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-06-18T13:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99974#M28054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS has no choice.&amp;nbsp; It doesn't have access to any previous values of N_MISSING.&amp;nbsp; It only has access to the current value.&amp;nbsp; (OK, technically we could use a LAG function if needed, but that's not in play here.)&amp;nbsp; When the top DO loop finishes, there is only one final value for N_MISSING and that is the value that the second DO loop can use.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jun 2013 14:48:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99974#M28054</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-06-18T14:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99975#M28055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great. .Thanks for your patience....This is a great place to learn and share the knowledge ....Also when the second loop brings in the same 2 records.......which statement in the code specifically says to put the value of the N_MISSING from prior loop to both the new&amp;nbsp; records.......&lt;STRONG&gt;Automatically retained?????&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thanks&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jun 2013 15:38:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99975#M28055</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-06-18T15:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99976#M28056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Automatically retained?&amp;nbsp; Sort of, and OK to think of it that way.&amp;nbsp; Again, consider a simpler DATA step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set old;&lt;/P&gt;&lt;P&gt;name='Fred';&lt;/P&gt;&lt;P&gt;if name='Fred' then x=5;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How does SAS know whether NAME is "Fred" when it gets to the IF/THEN statement?&amp;nbsp; Whatever value was assigned by earlier statements justs sits there, and is automatically available.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Technically, RETAIN in SAS has slightly different meaning.&amp;nbsp; It refers to the process that occurs when one observation is over and the next one begins.&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set old;&lt;/P&gt;&lt;P&gt;put 'X is now ' x;&lt;/P&gt;&lt;P&gt;name='Fred';&lt;/P&gt;&lt;P&gt;if name='Fred' then x=5;&lt;/P&gt;&lt;P&gt;* RETAIN X;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this program, both with and without the RETAIN statement, and it will illustrate the difference.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jun 2013 15:55:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99976#M28056</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-06-18T15:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99977#M28057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much.I appreciate your time&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jun 2013 16:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Subsetting/m-p/99977#M28057</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-06-18T16:41:11Z</dc:date>
    </item>
  </channel>
</rss>

