<?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: recode variable and missing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/252003#M47724</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure what the problem is? &amp;nbsp;Is seems to be a simple case of set the code column to 99, and then if weight gain is less than 15 set it to 00:&lt;/P&gt;
&lt;PRE&gt;data have;
  input id prejail_weight postjail_weight;
datalines;
100 120 65
101 80 140
102 200 175
103 110 178
104 999 999
105 . 90
;
run;

data want;
  set have;
  code="99";
  if (prejail_weight not in (.,999) and postjail_weight not in (.,999)) then do;
    if postjail_weight-prejail_weight &amp;lt; 15 then code="00";
  end;
run;
&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 Feb 2016 10:17:28 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-02-24T10:17:28Z</dc:date>
    <item>
      <title>recode variable and missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/251953#M47703</link>
      <description>&lt;P&gt;Hi all, I want to&amp;nbsp;compute incarceration weight gain using only&amp;nbsp;valid values.&lt;/P&gt;&lt;P&gt;Values of 999 &amp;nbsp;and . are considered invalid and should not be considered&amp;nbsp;.&lt;/P&gt;&lt;P&gt;see below data&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;ID&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;prejail_weight&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;postjail_weight&lt;/P&gt;&lt;/TD&gt;&l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gt;&lt;TD&gt;&lt;P&gt;107&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;189&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;76&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;108&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;69&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;89&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;109&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;125&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;110&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;110&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;105&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;85&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;111&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;210&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;210&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some tranformations are required as well.&lt;/P&gt;&lt;P&gt;1-weight gain is&amp;nbsp;to be coded 00 if weight gain &amp;nbsp;is less than -15 pounds.&lt;/P&gt;&lt;P&gt;2-weight gain is&amp;nbsp;&amp;nbsp;to be coded 99 if &amp;nbsp;weight &amp;nbsp;gain is-15 pounds or more.&lt;/P&gt;&lt;P&gt;3- weight gain is to be coded 99 if weight gain is missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any&amp;nbsp;help would be appreciated.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 03:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/251953#M47703</guid>
      <dc:creator>archibald</dc:creator>
      <dc:date>2016-02-24T03:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: recode variable and missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/251954#M47704</link>
      <description>&lt;P&gt;Which part are you having trouble with? You say incarceration weight gain, will that be post-pre?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you post the code you have so far? You mention changing values to 99, would those then be considered invalid?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 03:57:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/251954#M47704</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-24T03:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: recode variable and missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/252003#M47724</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure what the problem is? &amp;nbsp;Is seems to be a simple case of set the code column to 99, and then if weight gain is less than 15 set it to 00:&lt;/P&gt;
&lt;PRE&gt;data have;
  input id prejail_weight postjail_weight;
datalines;
100 120 65
101 80 140
102 200 175
103 110 178
104 999 999
105 . 90
;
run;

data want;
  set have;
  code="99";
  if (prejail_weight not in (.,999) and postjail_weight not in (.,999)) then do;
    if postjail_weight-prejail_weight &amp;lt; 15 then code="00";
  end;
run;
&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Feb 2016 10:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/252003#M47724</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-24T10:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: recode variable and missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/252623#M47994</link>
      <description>I am having some issues when it comes to code the difference(post-pre weight). the value 99 of (post-pre weight) should be considered missing.&lt;BR /&gt;See specifications below:&lt;BR /&gt;&lt;BR /&gt;1-weight gain is to be coded 00 if weight gain is less than -15 pounds.&lt;BR /&gt;2-weight gain is to be coded 99 if weight gain is-15 pounds or more.&lt;BR /&gt;3- weight gain is to be coded 99 if weight gain is missing.&lt;BR /&gt;4- else weight gain =weight gain</description>
      <pubDate>Fri, 26 Feb 2016 02:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/252623#M47994</guid>
      <dc:creator>archibald</dc:creator>
      <dc:date>2016-02-26T02:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: recode variable and missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/252625#M47995</link>
      <description>the code does not work. the difference post weight and pre weight returns 2 frequencies 00 and 99for all the cases.&lt;BR /&gt;I need to have an output similar to the one below where difference between post weight and pre weight is coded 00 and 99 as needed , else the values stay unchanged.&lt;BR /&gt;&lt;BR /&gt;weight_gain&lt;BR /&gt;60&lt;BR /&gt;00&lt;BR /&gt;68&lt;BR /&gt;924&lt;BR /&gt;99&lt;BR /&gt;20&lt;BR /&gt;00&lt;BR /&gt;99&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Feb 2016 02:59:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/252625#M47995</guid>
      <dc:creator>archibald</dc:creator>
      <dc:date>2016-02-26T02:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: recode variable and missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/252626#M47996</link>
      <description>&lt;P&gt;If you're going to analyze this data, I don't recommend doing this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll end up having to filter out the 0 and 99 for all your analytical procs, but it's better to leave them as missing in my opinion.&lt;/P&gt;
&lt;P&gt;SAS has several ways to identify missing values, so you may to consider using those instead.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000992455.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000992455.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;&amp;nbsp;code seems correct, does it not do what you'd like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check for missing values, if there are any, don't calculate the weight_gain since you can't.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then code them to different missing values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've used different variable names since it's easier to type out so make sure to replace the variables with yours as required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if nmiss(post, pre) =0 then weight_gain = post - pre;

if 0 &amp;lt; weight_gain &amp;lt; 15 then weight_gain = .A;
else if weight_gain &amp;gt;  15 then weight_gain = .B;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Feb 2016 03:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/252626#M47996</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-26T03:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: recode variable and missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/254391#M48512</link>
      <description>Thank you very much, Reeza</description>
      <pubDate>Fri, 04 Mar 2016 01:40:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/recode-variable-and-missing/m-p/254391#M48512</guid>
      <dc:creator>archibald</dc:creator>
      <dc:date>2016-03-04T01:40:29Z</dc:date>
    </item>
  </channel>
</rss>

