<?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 Ignoring missing values in Do Loop in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Ignoring-missing-values-in-Do-Loop/m-p/723337#M9829</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am having some issues with an array and do loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;CODE:&lt;/P&gt;&lt;P&gt;data lettergrade;&lt;BR /&gt;set detailrounded;&lt;BR /&gt;array english_array[*] _numeric_;&lt;BR /&gt;do i = 1 to dim(english_array);&lt;BR /&gt;if english&amp;gt;=90 then englishgrade="A";&lt;BR /&gt;if english&amp;gt;=75 and english&amp;lt;=89 then englishgrade="B";&lt;BR /&gt;if english&amp;gt;=60 and english&amp;lt;=74 then englishgrade="C";&lt;BR /&gt;if english&amp;lt;=60 then englishgrade="D";&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some of my values are missing and I did not want SAS to automatically assign a letter grade of "D". Is there anyway to exclude any missing data points so no letter grade shows up?&amp;nbsp;&lt;BR /&gt;Let me know if that makes sense or if clarification is needed!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Mar 2021 01:01:18 GMT</pubDate>
    <dc:creator>ellpap</dc:creator>
    <dc:date>2021-03-04T01:01:18Z</dc:date>
    <item>
      <title>Ignoring missing values in Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Ignoring-missing-values-in-Do-Loop/m-p/723337#M9829</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am having some issues with an array and do loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;CODE:&lt;/P&gt;&lt;P&gt;data lettergrade;&lt;BR /&gt;set detailrounded;&lt;BR /&gt;array english_array[*] _numeric_;&lt;BR /&gt;do i = 1 to dim(english_array);&lt;BR /&gt;if english&amp;gt;=90 then englishgrade="A";&lt;BR /&gt;if english&amp;gt;=75 and english&amp;lt;=89 then englishgrade="B";&lt;BR /&gt;if english&amp;gt;=60 and english&amp;lt;=74 then englishgrade="C";&lt;BR /&gt;if english&amp;lt;=60 then englishgrade="D";&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some of my values are missing and I did not want SAS to automatically assign a letter grade of "D". Is there anyway to exclude any missing data points so no letter grade shows up?&amp;nbsp;&lt;BR /&gt;Let me know if that makes sense or if clarification is needed!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 01:01:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Ignoring-missing-values-in-Do-Loop/m-p/723337#M9829</guid>
      <dc:creator>ellpap</dc:creator>
      <dc:date>2021-03-04T01:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: Ignoring missing values in Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Ignoring-missing-values-in-Do-Loop/m-p/723342#M9830</link>
      <description>&lt;P&gt;if 0 &amp;lt;= english_grade[i]&amp;lt;=60 then englishgrade="D";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;would be the approach.&lt;/P&gt;
&lt;P&gt;If you actually have more than one variable your "grade" is only going to be for the last variable. If you need more then you need to have a matching character array.&lt;/P&gt;
&lt;P&gt;I have to assume you meant to use the english_grade[i] otherwise you are repeating the exact same code for the variable "english" not the ones in the array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another approach for reporting purposes is to create a custom format such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc format;
value grade
90 - high = 'A'
75 - 89    = 'B'
60 - 74    = 'C'
0   -&amp;lt;60   = 'D'
other       = ' '
;
run;&lt;/PRE&gt;
&lt;P&gt;Then when you print or display the value associate the format with the variable:&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;
&lt;PRE&gt;proc print data=detailedrounded;
   var _numeric_;
   format _numeric_ grade. ;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SAS formats are a very powerful part of SAS. Any display for a single variable can use this. One advantage is you could have multiple formats , such gradecurve, that uses a slightly different range. The only change you would need is to associate the format with the variable(s) of interest.&lt;/P&gt;
&lt;P&gt;Groups created by formats are used by most of the analysis, graphing and reporting procedures.&lt;/P&gt;
&lt;P&gt;Try&lt;/P&gt;
&lt;PRE&gt;proc freq data=detailedrounded;
   tables _numeric_;
   format _numeric_ grade. ;
run;&lt;/PRE&gt;
&lt;P&gt;to see an example (after running the proc format code to make the format).&lt;/P&gt;
&lt;P&gt;You do need to make sure the format is available in the current session such as run the format code before use.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 01:57:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Ignoring-missing-values-in-Do-Loop/m-p/723342#M9830</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-04T01:57:16Z</dc:date>
    </item>
  </channel>
</rss>

