<?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: N (not missing)  for Q1-Q5. How to calculate Not missing two or more quizzes for each given stud in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/395135#M95235</link>
    <description>&lt;P&gt;&lt;A href="https://support.sas.com/downloads/package.htm?pid=1709#" target="_blank"&gt;https://support.sas.com/downloads/package.htm?pid=1709#&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's 120 files of various types in the link above.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The link you referenced had 58 files.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Sep 2017 15:12:28 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-09-12T15:12:28Z</dc:date>
    <item>
      <title>N (not missing)  for Q1-Q5. How to calculate Not missing two or more quizzes for each given student</title>
      <link>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/394900#M95162</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am learning from SAS by Example. Here is a relatively simple problem that&amp;nbsp; I do not have the answer for, but someone on here probably knows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, each student has taken up to 5 quizzes, with a score from 1 to 5, but some quizzes are missing for some students. I have learned from Learning SAS by Example how to exclude Max Min, mean etc. calculations using the N function if, for example, the total number of missing quizzes is more than 7. However, what if I want to exclude calculating the max, min, mean, etc for any given student who hasn't taken at least 4 quizes (ie. who has 2 or more quizzes missing). .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All my programming is below. Any help would be very much appreciated. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;----------------------------------------------------&lt;/P&gt;&lt;P&gt;Here is the original data file:&lt;/P&gt;&lt;P&gt;----------------------------------------&lt;/P&gt;&lt;P&gt;libname SASdata '/folders/myfolders/SASData' ;&lt;BR /&gt;&lt;BR /&gt;Data SASData.surveyMy ;&lt;BR /&gt;Input Subj$ Gender$ Age Income Q1 Q2 Q3 Q4 Q5 ;&lt;BR /&gt;&lt;BR /&gt;Datalines ;&lt;BR /&gt;001 M 23 28000 1 . 1 2 3&lt;BR /&gt;002 F 55 76123 4 5 2 1 1&lt;BR /&gt;003 M 38 36500 2 2 2 2 1&lt;BR /&gt;004 F 67 128000 4 3 2 2 4&lt;BR /&gt;005 M 22 23060 3 3 3 4 2&lt;BR /&gt;006 M 63 90000 2 3 5 4 3&lt;BR /&gt;007 F 45 76100 5 . . 3 3&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see, there are 7 total missing quizzes. Student 007 has two missing quizzes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the data that calculates max, min, and mean only if a total of 7 or less quizzes is missing:&lt;/P&gt;&lt;P&gt;libname sasdata '/folders/myfolders/SASData' ;&lt;BR /&gt;&lt;BR /&gt;Data Prob11_4 ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Set sasdata.surveymy ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If n(of Q1-Q5) lt 7 then Maxscore = Max(of Q1-Q5) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If n(of Q1-Q5) lt 7 then SecondHiScore = Max(Q1-Q5, 2) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If n(of Q1-Q5) lt 7 then Minscore = Min(of Q1-Q5) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If n(of Q1-Q5) lt 7 then QuesAve = Mean(of Q1-Q5) ;&lt;BR /&gt;run ;&lt;BR /&gt;&lt;BR /&gt;Now, how do I write code which calculates the Max, Min, and Mean for all students EXCEPT a student which has 2 missing quizzes. In this example, that is student 007.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 21:03:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/394900#M95162</guid>
      <dc:creator>ManitobaMoose</dc:creator>
      <dc:date>2017-09-11T21:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: N (not missing)  for Q1-Q5. How to calculate Not missing two or more quizzes for each given stud</title>
      <link>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/394904#M95165</link>
      <description>&lt;P&gt;Sorry. I meant to say, "As you can see. there are 3 missing quizzes". (not 7).&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 21:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/394904#M95165</guid>
      <dc:creator>ManitobaMoose</dc:creator>
      <dc:date>2017-09-11T21:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: N (not missing)  for Q1-Q5. How to calculate Not missing two or more quizzes for each given stud</title>
      <link>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/394925#M95174</link>
      <description>&lt;P&gt;Perhaps you want to use NMISS, the number of missing to exclude.&lt;/P&gt;
&lt;P&gt;I was very curious about about why you used n(of Q1-Q5) lt 7. Since there are only 5 variables the number of nonmissing values is always less than 7.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Provide your exact rule for when not to calculate some statistic. One example doesn't provide a rule. Do you require 3 , 4 or 5 values to calculate a valid mean? What value to you want if the mean isn't valid? Missing or some other code value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may also be interested in the Largest function.&lt;/P&gt;
&lt;P&gt;largest(2,q1,q2,q3,q4,q5) will return the second largest value. Max with the 2 as you used would return 2 if all of the Q values were 1.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 22:01:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/394925#M95174</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-11T22:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: N (not missing)  for Q1-Q5. How to calculate Not missing two or more quizzes for each given stud</title>
      <link>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/394945#M95185</link>
      <description>&lt;P&gt;Instead of runing the same IF test 4 times, run it once.&amp;nbsp; If the test is successful (NMISS&amp;gt;=2) then do the 4 calculations inside a "do group":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    if nmiss(of Q1-Q5)  ge 2 then do;
      Maxscore = Max(of Q1-Q5) ;
      SecondHiScore = Max(Q1-Q5, 2) ;
      Minscore = Min(of Q1-Q5) ;
      QuesAve = Mean(of Q1-Q5) ; 
    end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But your second stat&amp;nbsp;&amp;nbsp; "SecondHiScore=max(q1-a5,2)" is meaningless.&amp;nbsp; It just adds the value &lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt; to your list of values for X1 through X5&amp;nbsp; Take a look at the documentation on the &lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;ORDINAL&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt; function.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 22:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/394945#M95185</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-09-11T22:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: N (not missing)  for Q1-Q5. How to calculate Not missing two or more quizzes for each given stud</title>
      <link>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/394956#M95190</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for answering.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason I used n(of Q1-Q5) lt 7. is that I was following the problem in the Book Learning SAS by example. The great frustration I am having with that book is that it used to come with a CD that contained the practice problems that are referred to in the book, but no longer does. I downloaded files associated with the book from th internet, but that link only contains a few of the problems in the book, and so in other cases I am using other datasets that came with the downloadable link to substitute for those not available to me. I didn't realize that the lt n(of Q1-Q5) lt 7 was referring to the number of errors per observation. I thought that meant the total for all observations. Now it makes sense to use a n(of Q1-Q5) lt 2 to exclude more than 2 missing data points per observation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did switch out the largest function in place of the max function. It appears the max function only takes the max, not the second or third etc largest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF ANYONE KNOWS WHERE I CAN FIND THE LINK FOR LEARNING SAS BY EXAMPLE THAT INCLUDES ALL THE DATA SETS THAT WERE SUPPOSED TO COME WITH THE BOOK THAT WOULD BE EXTREMELY HELPFUL.&amp;nbsp; I have the book with the red cover.&amp;nbsp; It says it was originally published in 2007.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 23:09:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/394956#M95190</guid>
      <dc:creator>ManitobaMoose</dc:creator>
      <dc:date>2017-09-11T23:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: N (not missing)  for Q1-Q5. How to calculate Not missing two or more quizzes for each given stud</title>
      <link>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/394957#M95191</link>
      <description>&lt;P&gt;This is the website I used to download the files. I would say that less than 25% of the files referred to in the book problems can be found at this link:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.sas.com/publishing/authors/extras/60864_code.pdf" target="_blank"&gt;https://support.sas.com/publishing/authors/extras/60864_code.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 23:19:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/394957#M95191</guid>
      <dc:creator>ManitobaMoose</dc:creator>
      <dc:date>2017-09-11T23:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: N (not missing)  for Q1-Q5. How to calculate Not missing two or more quizzes for each given stud</title>
      <link>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/395135#M95235</link>
      <description>&lt;P&gt;&lt;A href="https://support.sas.com/downloads/package.htm?pid=1709#" target="_blank"&gt;https://support.sas.com/downloads/package.htm?pid=1709#&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's 120 files of various types in the link above.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The link you referenced had 58 files.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2017 15:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/N-not-missing-for-Q1-Q5-How-to-calculate-Not-missing-two-or-more/m-p/395135#M95235</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-12T15:12:28Z</dc:date>
    </item>
  </channel>
</rss>

