<?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 Using proc formats to replace only numerical answer in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-proc-formats-to-replace-only-numerical-answer/m-p/805414#M317267</link>
    <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am taking data from a survey that is numerical. The questions is how many days in a month have you had good mental health days. In the code book 0 days= 88 but 1 day is just 1 and so on. I need to change the 88 to 0 without messing up other numbers of days like 10, 20, 30 (ultimately need to look at the avg and the 88 is messing this obviously). My current code does not do that- my dataset puts in a (*) when it is 10,20,30. Here is what I have so far. Thanks so much!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc format; &lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;value menthlth&lt;/DIV&gt;&lt;DIV&gt;88= 0&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data sasfile.Final_subset2;&lt;/DIV&gt;&lt;DIV&gt;set sasfile.Final_subset;&lt;/DIV&gt;&lt;DIV&gt;format&amp;nbsp; menthlth menthlth. ; /*apply formats to created variables*/&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 31 Mar 2022 23:57:50 GMT</pubDate>
    <dc:creator>almay2121</dc:creator>
    <dc:date>2022-03-31T23:57:50Z</dc:date>
    <item>
      <title>Using proc formats to replace only numerical answer</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-proc-formats-to-replace-only-numerical-answer/m-p/805414#M317267</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am taking data from a survey that is numerical. The questions is how many days in a month have you had good mental health days. In the code book 0 days= 88 but 1 day is just 1 and so on. I need to change the 88 to 0 without messing up other numbers of days like 10, 20, 30 (ultimately need to look at the avg and the 88 is messing this obviously). My current code does not do that- my dataset puts in a (*) when it is 10,20,30. Here is what I have so far. Thanks so much!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc format; &lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;value menthlth&lt;/DIV&gt;&lt;DIV&gt;88= 0&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data sasfile.Final_subset2;&lt;/DIV&gt;&lt;DIV&gt;set sasfile.Final_subset;&lt;/DIV&gt;&lt;DIV&gt;format&amp;nbsp; menthlth menthlth. ; /*apply formats to created variables*/&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 23:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-proc-formats-to-replace-only-numerical-answer/m-p/805414#M317267</guid>
      <dc:creator>almay2121</dc:creator>
      <dc:date>2022-03-31T23:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc formats to replace only numerical answer</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-proc-formats-to-replace-only-numerical-answer/m-p/805417#M317269</link>
      <description>&lt;P&gt;You could do something as below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  do menthlth=-1, 0, 1, 10, 30, 31, 32, 88;
    output;
  end;

  stop;
run;

proc format;
  invalue menthlth
    low-&amp;lt;0= .
    31&amp;lt;-high=.
    other=_same_
  ;
run;

data want;
  set have;
  menthlth_recoded=input(menthlth, menthlth.) ; 
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Apr 2022 00:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-proc-formats-to-replace-only-numerical-answer/m-p/805417#M317269</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-04-01T00:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc formats to replace only numerical answer</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-proc-formats-to-replace-only-numerical-answer/m-p/805421#M317273</link>
      <description>Why complicate things with formats?&lt;BR /&gt;&lt;BR /&gt;if mentlhlth = 88 then mentlhlth = 0;</description>
      <pubDate>Fri, 01 Apr 2022 01:41:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-proc-formats-to-replace-only-numerical-answer/m-p/805421#M317273</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-04-01T01:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc formats to replace only numerical answer</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-proc-formats-to-replace-only-numerical-answer/m-p/805528#M317327</link>
      <description>&lt;P&gt;If you want to use the value for CALCULATIONS, such as mean number of good health days then you want to have a value of 0. Which means a format is not going to help. Formats are only related to Displaying values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Options: Recode the value(s) you don't want for calculation into either the same variable (caution applies) or into a new variable.&lt;/P&gt;
&lt;P&gt;Another is if the data is read from a text file to use an INFORMAT that does that mapping when the value is first read. Which might look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc format;
invalue read88to0_
88=0
99=.R
77=.D
other=[2.]
;
run;

/* in a data step to read the file*/

Informat menthlth read88to0_.&lt;/PRE&gt;
&lt;P&gt;Note the informat I propose will read values of 77 and 99 to special missing so you can follow that the original question had a response like 'Don't Know' or 'Refused' if those are the meanings for 77 and 99 (from similar survey data).&lt;/P&gt;
&lt;P&gt;This way you can tell why specific values are missing and use them if needed by testing for the .D or .R missing value, such as possibly imputing only some of the values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 15:21:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-proc-formats-to-replace-only-numerical-answer/m-p/805528#M317327</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-01T15:21:59Z</dc:date>
    </item>
  </channel>
</rss>

