<?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 Replacing NA with 0 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replacing-NA-with-0/m-p/605004#M175482</link>
    <description>&lt;P&gt;I am trying to replace the NA values for 0 in the 5 markdown variables. The first time, I tried using the method from one of these other community message, and it worked. I took down notes and tried it again and now it isn't working. Instead what it's doing is creating a new variable field "NA" with no values in it. I attached pictures of the import data resulting from the code I'm using. I have little to no experience coding so it may be something relatively obvious! I'm using the University Edition, Basic 3.8.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA work.import;
	set work.import;
	array change _character_;
		do over change;
		if change=NA then change=0;
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 18 Nov 2019 14:00:33 GMT</pubDate>
    <dc:creator>MicheleB0108</dc:creator>
    <dc:date>2019-11-18T14:00:33Z</dc:date>
    <item>
      <title>Replacing NA with 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-NA-with-0/m-p/605004#M175482</link>
      <description>&lt;P&gt;I am trying to replace the NA values for 0 in the 5 markdown variables. The first time, I tried using the method from one of these other community message, and it worked. I took down notes and tried it again and now it isn't working. Instead what it's doing is creating a new variable field "NA" with no values in it. I attached pictures of the import data resulting from the code I'm using. I have little to no experience coding so it may be something relatively obvious! I'm using the University Edition, Basic 3.8.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA work.import;
	set work.import;
	array change _character_;
		do over change;
		if change=NA then change=0;
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2019 14:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-NA-with-0/m-p/605004#M175482</guid>
      <dc:creator>MicheleB0108</dc:creator>
      <dc:date>2019-11-18T14:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing NA with 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-NA-with-0/m-p/605008#M175485</link>
      <description>&lt;P&gt;Please try the below code, I guess the NA need to be in quotes also the 0 as the 5 variables are character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA work.import;
	set work.import;
	array change _character_;
		do over change;
		if change='NA' then change='0';
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2019 14:08:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-NA-with-0/m-p/605008#M175485</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-11-18T14:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing NA with 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-NA-with-0/m-p/605014#M175486</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are your variables really of character nature or did the import make them character because&lt;/P&gt;
&lt;P&gt;of "NA" observations ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your variables are numeric then use numeric columns to store them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use an informat to interpret "NA" as missing values or zeros :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    invalue mynum
        'NA'=0;
run;

data have;
    informat x mynum.;
    input x;
    cards;
1
2
NA
5
NA
3
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2019 14:23:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-NA-with-0/m-p/605014#M175486</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-11-18T14:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing NA with 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-NA-with-0/m-p/605017#M175488</link>
      <description>&lt;P&gt;Adding on to the excellent advice by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30622"&gt;@gamotte&lt;/a&gt;, you might be better served as keeping NA as missing rather than numeric zero, which can screw up averages and any other statistics you want to compute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    invalue mynum 'NA'=.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2019 14:30:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-NA-with-0/m-p/605017#M175488</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-18T14:30:46Z</dc:date>
    </item>
  </channel>
</rss>

