<?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 set unformatted values to missing in data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-unformatted-values-to-missing-in-data-step/m-p/240036#M44244</link>
    <description>&lt;P&gt;I do a large amount of research suvey analysis. &amp;nbsp;Often (too often), we get responses which are invalid. &amp;nbsp;By invalid, I mean they&lt;/P&gt;
&lt;P&gt;show up as numbers rather than the formatted value in PROC FREQ.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example :&lt;/P&gt;
&lt;P&gt;proc format;&lt;/P&gt;
&lt;P&gt;format fclass &amp;nbsp;1 = 'Freshman'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 = 'Sophomore'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3 = 'Junior'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4 = 'Senior';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This format is applied to a numeric variable which should have values between 1 and 4 :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format class fclass.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What ultimately happens is that respondents code numbers outside the allowable range (as in the proc format statement) :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Running PROC FREQ for this variable, I get :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Freshman &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;/P&gt;
&lt;P&gt;Sophomore &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11&lt;/P&gt;
&lt;P&gt;Junior &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;23&lt;/P&gt;
&lt;P&gt;Senior &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there an easy way to automatically set the erroneous unformatted values (i.e. 5 and 6 in this example) to missing numeric values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I've been doing is manually programming blocks of code for every question that has one or more invalid values :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if class GT 4 then class=.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there an easier way to do this ? &amp;nbsp;Survey respondents tend to code copious amounts of invalid answers sometimes...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Barry Walton&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Barry.Walton@millersville.edu&lt;/P&gt;</description>
    <pubDate>Fri, 18 Dec 2015 16:06:46 GMT</pubDate>
    <dc:creator>enginemane44</dc:creator>
    <dc:date>2015-12-18T16:06:46Z</dc:date>
    <item>
      <title>How to set unformatted values to missing in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-unformatted-values-to-missing-in-data-step/m-p/240036#M44244</link>
      <description>&lt;P&gt;I do a large amount of research suvey analysis. &amp;nbsp;Often (too often), we get responses which are invalid. &amp;nbsp;By invalid, I mean they&lt;/P&gt;
&lt;P&gt;show up as numbers rather than the formatted value in PROC FREQ.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example :&lt;/P&gt;
&lt;P&gt;proc format;&lt;/P&gt;
&lt;P&gt;format fclass &amp;nbsp;1 = 'Freshman'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 = 'Sophomore'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3 = 'Junior'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4 = 'Senior';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This format is applied to a numeric variable which should have values between 1 and 4 :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format class fclass.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What ultimately happens is that respondents code numbers outside the allowable range (as in the proc format statement) :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Running PROC FREQ for this variable, I get :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Freshman &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;/P&gt;
&lt;P&gt;Sophomore &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11&lt;/P&gt;
&lt;P&gt;Junior &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;23&lt;/P&gt;
&lt;P&gt;Senior &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there an easy way to automatically set the erroneous unformatted values (i.e. 5 and 6 in this example) to missing numeric values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I've been doing is manually programming blocks of code for every question that has one or more invalid values :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if class GT 4 then class=.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there an easier way to do this ? &amp;nbsp;Survey respondents tend to code copious amounts of invalid answers sometimes...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Barry Walton&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Barry.Walton@millersville.edu&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 16:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-unformatted-values-to-missing-in-data-step/m-p/240036#M44244</guid>
      <dc:creator>enginemane44</dc:creator>
      <dc:date>2015-12-18T16:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to set unformatted values to missing in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-unformatted-values-to-missing-in-data-step/m-p/240038#M44246</link>
      <description>&lt;P&gt;You can set an Other in the format, i.e.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
format fclass  1 = 'Freshman'
                       2 = 'Sophomore'
                       3 = 'Junior'
                       4 = 'Senior'
                       other = 'Other'
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can set the label to a missing character, whatever fits your need best.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 16:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-unformatted-values-to-missing-in-data-step/m-p/240038#M44246</guid>
      <dc:creator>JoshB</dc:creator>
      <dc:date>2015-12-18T16:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to set unformatted values to missing in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-unformatted-values-to-missing-in-data-step/m-p/240041#M44248</link>
      <description>&lt;P&gt;Two basic approaches depending on how concerned anyone is about out of specified range values.&lt;/P&gt;
&lt;P&gt;First is you use an informat that matches your expected values, for your example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format&lt;/P&gt;
&lt;P&gt;invalue fclass&lt;/P&gt;
&lt;P&gt;1,2,3,4 = _same_&lt;/P&gt;
&lt;P&gt;other = .&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;And read the data with that informat. If you have an Excel file, save to CSV and read that to have control.&lt;/P&gt;
&lt;P&gt;One advantage of the informat approach is that surveys often have many questions with the same coding schemes and you can use the same format for all of the questions with the same scheme.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 16:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-unformatted-values-to-missing-in-data-step/m-p/240041#M44248</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-12-18T16:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to set unformatted values to missing in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-unformatted-values-to-missing-in-data-step/m-p/240048#M44251</link>
      <description>&lt;P&gt;This is probably a good time for you to learn about the advanced features of PROC SUMMARY. &amp;nbsp;This example uses the EXCLUSIVE and PRELOADFMT options to achieve the result using only subset implied by the VALUE format. &amp;nbsp;Note also the use of option COMPLETETYPES I'll leave it to use to research what that option does when you remove the "*" from line three of the program.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
   input class freq @@;
   *if class eq 2 then delete;
   cards;
1  4  2 11  3 23  4 13  5  1  6  1
;;;;
   run;
proc print;
   run;
proc format;
   value class  1='Freshman' 2='Sophomore' 3='Junior' 4='Senior';
   run;
proc summary data=class nway completetypes;
   class class / exclusive preloadfmt;
   freq freq;
   format class class.;
   output out=counts(drop=_type_);
   run;
proc print;
   run;
proc freq;
   tables class / nocum;
   weight _freq_;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1252i9B25BDB5E8761AB6/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 16:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-unformatted-values-to-missing-in-data-step/m-p/240048#M44251</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-12-18T16:37:44Z</dc:date>
    </item>
  </channel>
</rss>

