<?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: Handling missing values when variable converted from numeric to character in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Handling-missing-values-when-variable-converted-from-numeric-to/m-p/568157#M159887</link>
    <description>&lt;P&gt;First you create a dataset with "by subject", which only works if the source is already sorted by subject, so the following sort serves no purpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you create character variable misd_, but never use it, and discard it immediately.&lt;/P&gt;
&lt;P&gt;Have you inspected misd for its values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post some example data for dataset screener, and tell us what you expect as a result for each observation. Use a data step with datalines to post example data in a usable way.&lt;/P&gt;</description>
    <pubDate>Sat, 22 Jun 2019 20:23:33 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-06-22T20:23:33Z</dc:date>
    <item>
      <title>Handling missing values when variable converted from numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Handling-missing-values-when-variable-converted-from-numeric-to/m-p/568154#M159884</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to convert numeric to character value for one of the variables, but the missing values are taking the values.&lt;/P&gt;&lt;P&gt;Can some one suggest a way that the missing values are displayed as missing value or correct me what I am missing in the code?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nasya&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*------------------------------------------------------------------------------*;
* Screener data set
*------------------------------------------------------------------------------*;
data screener (keep=subject age misd dispos);
&amp;nbsp; &amp;nbsp; &amp;nbsp; set pdata.screener;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;by subject;
run;

/*Sort the data*/
proc sort data= screener;
&amp;nbsp; &amp;nbsp; &amp;nbsp; by subject;
run;


data screenerfinal;
&amp;nbsp; &amp;nbsp; set screener;
&amp;nbsp; &amp;nbsp; attrib TEST length=$200; /*Convert numeric to character and new variable is assigned*/

&amp;nbsp; &amp;nbsp;if dispos eq 6 then delete;/*Did not qualify*/

&amp;nbsp; &amp;nbsp;misd_=put(misd, best.);

&amp;nbsp; &amp;nbsp;if misd le 5 then TEST = ' Normal Level';
&amp;nbsp; &amp;nbsp;else if misd &amp;gt; 5 then TEST = ' Low Level';
&amp;nbsp; &amp;nbsp;else if misd eq . then TEST= ' ';&amp;nbsp;

&amp;nbsp; &amp;nbsp; keep subject age misd test dispos;

run;


proc sort data= screenerfinal;
&amp;nbsp; &amp;nbsp; by subject;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 22 Jun 2019 19:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Handling-missing-values-when-variable-converted-from-numeric-to/m-p/568154#M159884</guid>
      <dc:creator>Nasya</dc:creator>
      <dc:date>2019-06-22T19:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: Handling missing values when variable converted from numeric to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Handling-missing-values-when-variable-converted-from-numeric-to/m-p/568157#M159887</link>
      <description>&lt;P&gt;First you create a dataset with "by subject", which only works if the source is already sorted by subject, so the following sort serves no purpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you create character variable misd_, but never use it, and discard it immediately.&lt;/P&gt;
&lt;P&gt;Have you inspected misd for its values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post some example data for dataset screener, and tell us what you expect as a result for each observation. Use a data step with datalines to post example data in a usable way.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jun 2019 20:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Handling-missing-values-when-variable-converted-from-numeric-to/m-p/568157#M159887</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-22T20:23:33Z</dc:date>
    </item>
  </channel>
</rss>

