<?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: How to Fix Missing Values that Turned Numeric Variables to Character Variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Fix-Missing-Values-that-Turned-Numeric-Variables-to/m-p/947442#M370898</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/470428"&gt;@unwashedhelimix&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the reply! I just saw it after revising my question a bit. I appreciate the guidance on the conversion, but I thought it would be a better report if the missing cells (not the entire row) were deleted.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I do not know what you mean by that comment.&amp;nbsp; &amp;nbsp;There is no need to delete observations (or values).&amp;nbsp; Can you explain what you meant more clearly?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have data as you posted (with numeric variables) SAS will handle it properly.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Age Points Assists Rebounds Steals;
cards;
21 12.1  7.2 7.4 1.2
26 20.3  7.2  .  1.2
21 10     .  7.4  .
19  8.4 10.1  .  2.3
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For example the mean values will be calculated using only the non-missing values.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;The MEANS Procedure

Variable    N            Mean         Std Dev         Minimum         Maximum
-----------------------------------------------------------------------------
Age         4      21.7500000       2.9860788      19.0000000      26.0000000
Points      4      12.7000000       5.2883520       8.4000000      20.3000000
Assists     3       8.1666667       1.6743158       7.2000000      10.1000000
Rebounds    2       7.4000000               0       7.4000000       7.4000000
Steals      3       1.5666667       0.6350853       1.2000000       2.3000000
-----------------------------------------------------------------------------

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Oct 2024 03:18:09 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-10-15T03:18:09Z</dc:date>
    <item>
      <title>How to Fix Missing Values that Turned Numeric Variables to Character Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Fix-Missing-Values-that-Turned-Numeric-Variables-to/m-p/947436#M370892</link>
      <description>&lt;P&gt;I have a data set called "BASKETBALL_ST" and it looks something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Age&amp;nbsp; &amp;nbsp;Points&amp;nbsp; &amp;nbsp;Assists&amp;nbsp; &amp;nbsp;Rebounds&amp;nbsp; &amp;nbsp;Steals&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;21&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7.2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7.4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.2&lt;/P&gt;&lt;P&gt;26&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20.3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7.2&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; &amp;nbsp; 1.2&lt;/P&gt;&lt;P&gt;21&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10.0&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;7.4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;19&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8.4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10.1&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; 2.3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to run a proc means for it, but the variables with missing values (Assists, Rebounds, Steals) become character values, so they're not showing up on the proc means output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I delete ONLY the cells with missing (not the whole row)? Age and points are numeric, so they are showing in the proc means report, as desired. However, I can't figure out how to delete the missing values without deleting an entire row. This is my code so far:&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;PRE&gt;proc import datafile="C:\Users\John\Downloads\SASLearn\SASLearnOct\BASKETBALL_ST.xls"
&amp;nbsp; &amp;nbsp;dbms=xls
&amp;nbsp; &amp;nbsp;out=work.BASKETBALL_ST
&amp;nbsp; &amp;nbsp;replace;

data work.cleanBASKETBALL_ST;
&amp;nbsp; &amp;nbsp;set work.BASKETBALL_ST;
&amp;nbsp; &amp;nbsp;if Assists=. then Assists=0;
&amp;nbsp; &amp;nbsp;if Rebounds=. then Rebounds=0;
&amp;nbsp; &amp;nbsp;if Rebounds=. then Rebounds=0;
run;

proc means data=work.cleanBASKETBALL_ST n mean median std min max range maxdec=2;
run;&lt;/PRE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This still yields a proc means report with only the variables Age and Points. At the end after deleting the missing values, Age &amp;amp; Points should have 4 observations, Assists should have 3, Rebounds should have 2, Steals should have 3.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;After that is taken care of, I'm also stumped on how to utilize the input() statement to convert these back to numeric.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 15 Oct 2024 02:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Fix-Missing-Values-that-Turned-Numeric-Variables-to/m-p/947436#M370892</guid>
      <dc:creator>unwashedhelimix</dc:creator>
      <dc:date>2024-10-15T02:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to Fix Missing Values that Turned Numeric Variables to Character Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Fix-Missing-Values-that-Turned-Numeric-Variables-to/m-p/947438#M370894</link>
      <description>&lt;P&gt;You cannot change the type of an existing variable.&lt;/P&gt;
&lt;P&gt;So make new variables instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cleanBASKETBALL_ST;
   set BASKETBALL_ST;
   _1 = input(assists,32.);
   _2 = input(rebounds,32.);
   _3 = input(steals),32.);
   rename _1=Assists _2=Rebounds _3=Steals 
     Assists=Assists_char Rebounds=Rebounds_char Steals=Steals_char
   ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Take a look at your XLS file and try to figure out why it has character values in some of the cells in the columns that you want to be numbers.&amp;nbsp; Where did it come from?&amp;nbsp; Can you get the data as a CSV file instead?&amp;nbsp; With a text file, such as a CSV file, you can write your own data step to read in the data lines.&amp;nbsp; That way you will have complete control over how the variables are defined.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 02:12:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Fix-Missing-Values-that-Turned-Numeric-Variables-to/m-p/947438#M370894</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-15T02:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to Fix Missing Values that Turned Numeric Variables to Character Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Fix-Missing-Values-that-Turned-Numeric-Variables-to/m-p/947441#M370897</link>
      <description>&lt;P&gt;Thanks for the reply! I just saw it after revising my question a bit. I appreciate the guidance on the conversion, but I thought it would be a better report if the missing cells (not the entire row) were deleted.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 02:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Fix-Missing-Values-that-Turned-Numeric-Variables-to/m-p/947441#M370897</guid>
      <dc:creator>unwashedhelimix</dc:creator>
      <dc:date>2024-10-15T02:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to Fix Missing Values that Turned Numeric Variables to Character Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Fix-Missing-Values-that-Turned-Numeric-Variables-to/m-p/947442#M370898</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/470428"&gt;@unwashedhelimix&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the reply! I just saw it after revising my question a bit. I appreciate the guidance on the conversion, but I thought it would be a better report if the missing cells (not the entire row) were deleted.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I do not know what you mean by that comment.&amp;nbsp; &amp;nbsp;There is no need to delete observations (or values).&amp;nbsp; Can you explain what you meant more clearly?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have data as you posted (with numeric variables) SAS will handle it properly.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Age Points Assists Rebounds Steals;
cards;
21 12.1  7.2 7.4 1.2
26 20.3  7.2  .  1.2
21 10     .  7.4  .
19  8.4 10.1  .  2.3
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For example the mean values will be calculated using only the non-missing values.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;The MEANS Procedure

Variable    N            Mean         Std Dev         Minimum         Maximum
-----------------------------------------------------------------------------
Age         4      21.7500000       2.9860788      19.0000000      26.0000000
Points      4      12.7000000       5.2883520       8.4000000      20.3000000
Assists     3       8.1666667       1.6743158       7.2000000      10.1000000
Rebounds    2       7.4000000               0       7.4000000       7.4000000
Steals      3       1.5666667       0.6350853       1.2000000       2.3000000
-----------------------------------------------------------------------------

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 03:18:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Fix-Missing-Values-that-Turned-Numeric-Variables-to/m-p/947442#M370898</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-15T03:18:09Z</dc:date>
    </item>
  </channel>
</rss>

