<?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 do I replace all values for a variable with blanks or null in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/932265#M366733</link>
    <description>&lt;P&gt;I think that code was too specific, I was looking to null all of the values.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jun 2024 19:38:34 GMT</pubDate>
    <dc:creator>cc15</dc:creator>
    <dc:date>2024-06-13T19:38:34Z</dc:date>
    <item>
      <title>How do I replace all values for a variable with blanks or null</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/931791#M366576</link>
      <description>&lt;P&gt;I have a very large dataset and I am trying to replace several numeric and character variable values (trying to null all of the values with certain variables)&amp;nbsp; with either a blank or null (.). I tried the following code but got several error messages. Is this the best code or are there others?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc iml;&lt;BR /&gt;edit mp_;&lt;BR /&gt;read all var (Result1) where (Result1 ^= '0');&lt;BR /&gt;Result1 = ' ';&lt;BR /&gt;replace all var (Result1) where (Result1 ^= '0');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4 proc iml;&lt;BR /&gt;NOTE: Writing HTML Body file: sashtml.htm&lt;BR /&gt;NOTE: IML Ready&lt;BR /&gt;5 edit mp_;&lt;BR /&gt;6 read all var (Result1) where (Result1 ^= 0);&lt;BR /&gt;ERROR: Operand Result1 does not have a value.&lt;/P&gt;&lt;P&gt;statement : READ at line 6 column 1&lt;BR /&gt;7 Result1 = ' ';&lt;BR /&gt;8 replace all var (Result1) where (Result1 ^= 0);&lt;/P&gt;&lt;P&gt;ERROR: An exception has been encountered.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 20:01:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/931791#M366576</guid>
      <dc:creator>cc15</dc:creator>
      <dc:date>2024-06-11T20:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I replace all values for a variable with blanks or null</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/931792#M366577</link>
      <description>&lt;P&gt;Hi, in the data step you can use the call missing call routine.&lt;BR /&gt;e.g.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	set sashelp.class;
	if _n_ in (1 3 5 7 9) then call missing (of _all_); /*clear all variables*/
	else if _n_ in (2 4 6 8) then call missing (of name--height); /*clear variables between name and height, inclusive*/
	else call missing(of height weight); /*clear only height and weight*/
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope it helps&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 20:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/931792#M366577</guid>
      <dc:creator>Mazi</dc:creator>
      <dc:date>2024-06-11T20:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I replace all values for a variable with blanks or null</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/931800#M366583</link>
      <description>&lt;P&gt;I tried the following code recommended, but the variables were not nulled&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data mp_test;&lt;BR /&gt;set mp_;&lt;BR /&gt;if Result1 in ("Positive" "Unknown") then call missing (of _all_);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 20:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/931800#M366583</guid>
      <dc:creator>cc15</dc:creator>
      <dc:date>2024-06-11T20:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do I replace all values for a variable with blanks or null</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/931805#M366584</link>
      <description>&lt;P&gt;This version worked, thanks for the guidance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data mp_test;&lt;BR /&gt;set mp_;&lt;BR /&gt;call missing (Result1);&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 20:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/931805#M366584</guid>
      <dc:creator>cc15</dc:creator>
      <dc:date>2024-06-11T20:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I replace all values for a variable with blanks or null</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/931860#M366612</link>
      <description>I’m curious to understand why this did not work for you. &lt;BR /&gt;&lt;BR /&gt;Are you sure the values passed to the in operator are correct ? That is, that they the correctly cased since strings are case-sensitive, and spelled correctly, exactly as they appear in your data ?</description>
      <pubDate>Wed, 12 Jun 2024 04:53:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/931860#M366612</guid>
      <dc:creator>Mazi</dc:creator>
      <dc:date>2024-06-12T04:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I replace all values for a variable with blanks or null</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/932265#M366733</link>
      <description>&lt;P&gt;I think that code was too specific, I was looking to null all of the values.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 19:38:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/932265#M366733</guid>
      <dc:creator>cc15</dc:creator>
      <dc:date>2024-06-13T19:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I replace all values for a variable with blanks or null</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/932354#M366771</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466560"&gt;@cc15&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I think that code was too specific, I was looking to null all of the values.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The CALL MISSING(of _ALL_) is going to set ALL of the VARIABLES to missing but only on the observations where it runs.&lt;/P&gt;
&lt;P&gt;To set the variable to missing on every observation then do not use the IF/THEN.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or simpler still just DROP the variable, since a variable that is missing on every observation is not adding much information to the dataset and just just taking up space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2024 01:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-replace-all-values-for-a-variable-with-blanks-or-null/m-p/932354#M366771</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-06-14T01:20:48Z</dc:date>
    </item>
  </channel>
</rss>

