<?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 Dealing with non-numeric and Missing Value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-non-numeric-and-Missing-Value/m-p/670140#M201125</link>
    <description>&lt;P&gt;I have a column of data(visited_store) which have a mix of numeric, character and missing values.&lt;/P&gt;&lt;P&gt;Example: "Yes", "No", 99,100, .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create another column, and assign Yes to 1 and all other values to 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data clean_data;&lt;BR /&gt;set original_data;&lt;/P&gt;&lt;P&gt;if visited_store in ( . , 99, 999, 9999) then visited_store_clean = 0;&lt;/P&gt;&lt;P&gt;if&amp;nbsp;visited_store = "No" then&amp;nbsp;visited_store_clean = 0;&lt;/P&gt;&lt;P&gt;if&amp;nbsp;visited_store = "Yes" then&amp;nbsp;visited_store_clean = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;Does not seem to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help on how i can select rows with "No", missing value ( . ) and numeric values to 0, while "Yes" to 1?&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jul 2020 14:52:51 GMT</pubDate>
    <dc:creator>stacy_not_robot</dc:creator>
    <dc:date>2020-07-17T14:52:51Z</dc:date>
    <item>
      <title>Dealing with non-numeric and Missing Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-non-numeric-and-Missing-Value/m-p/670140#M201125</link>
      <description>&lt;P&gt;I have a column of data(visited_store) which have a mix of numeric, character and missing values.&lt;/P&gt;&lt;P&gt;Example: "Yes", "No", 99,100, .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create another column, and assign Yes to 1 and all other values to 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data clean_data;&lt;BR /&gt;set original_data;&lt;/P&gt;&lt;P&gt;if visited_store in ( . , 99, 999, 9999) then visited_store_clean = 0;&lt;/P&gt;&lt;P&gt;if&amp;nbsp;visited_store = "No" then&amp;nbsp;visited_store_clean = 0;&lt;/P&gt;&lt;P&gt;if&amp;nbsp;visited_store = "Yes" then&amp;nbsp;visited_store_clean = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;Does not seem to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help on how i can select rows with "No", missing value ( . ) and numeric values to 0, while "Yes" to 1?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 14:52:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dealing-with-non-numeric-and-Missing-Value/m-p/670140#M201125</guid>
      <dc:creator>stacy_not_robot</dc:creator>
      <dc:date>2020-07-17T14:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with non-numeric and Missing Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-non-numeric-and-Missing-Value/m-p/670141#M201126</link>
      <description>&lt;P&gt;Is this column of data in Excel, or a SAS data set, or somewhere else?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A variable in a SAS data set cannot have a mixture of character and numeric variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please explain further what you see and provide more details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are talking about a SAS data set, please convert it to SAS data step code so we can determine what you are seeing and determine how to proceed. Instructions:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_blank"&gt;https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 14:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dealing-with-non-numeric-and-Missing-Value/m-p/670141#M201126</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-17T14:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with non-numeric and Missing Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-non-numeric-and-Missing-Value/m-p/670146#M201128</link>
      <description>Thank you for your response.&lt;BR /&gt;This is a column from a sas dataset.&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jul 2020 15:22:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dealing-with-non-numeric-and-Missing-Value/m-p/670146#M201128</guid>
      <dc:creator>stacy_not_robot</dc:creator>
      <dc:date>2020-07-17T15:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with non-numeric and Missing Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-non-numeric-and-Missing-Value/m-p/670147#M201129</link>
      <description>&lt;P&gt;Run a proc contents on your variable to check the type and format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do this using proc contents.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=original_data;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In general, I would advise you to code Yes as 1, No as 0 and then 99, 9999, 999, . as missing. This way any summary statistics will be counted for correctly. You should also be using IF/ELSE IF not just IF statements.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data clean_data;
set original_data;

if missing(visited_store) or visited_store in ('99', '999', '9999', '.') then visited_store_clean = .;
else if visited_store = 'No' then visited_store_clean = 0;
else if visited_store = 'Yes' then visited_store_clean = 1;
else visited_store_clean = -99; *this is to check your coding hasn't missed any values;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338181"&gt;@stacy_not_robot&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a column of data(visited_store) which have a mix of numeric, character and missing values.&lt;/P&gt;
&lt;P&gt;Example: "Yes", "No", 99,100, .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to create another column, and assign Yes to 1 and all other values to 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data clean_data;&lt;BR /&gt;set original_data;&lt;/P&gt;
&lt;P&gt;if visited_store in ( . , 99, 999, 9999) then visited_store_clean = 0;&lt;/P&gt;
&lt;P&gt;if&amp;nbsp;visited_store = "No" then&amp;nbsp;visited_store_clean = 0;&lt;/P&gt;
&lt;P&gt;if&amp;nbsp;visited_store = "Yes" then&amp;nbsp;visited_store_clean = 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;P&gt;Does not seem to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help on how i can select rows with "No", missing value ( . ) and numeric values to 0, while "Yes" to 1?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 15:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dealing-with-non-numeric-and-Missing-Value/m-p/670147#M201129</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-17T15:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with non-numeric and Missing Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-non-numeric-and-Missing-Value/m-p/670151#M201131</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338181"&gt;@stacy_not_robot&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a column of data(visited_store) which have a mix of numeric, character and missing values.&lt;/P&gt;
&lt;P&gt;Example: "Yes", "No", 99,100, .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to create another column, and assign Yes to 1 and all other values to 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data clean_data;&lt;BR /&gt;set original_data;&lt;/P&gt;
&lt;P&gt;if visited_store in ( . , 99, 999, 9999) then visited_store_clean = 0;&lt;/P&gt;
&lt;P&gt;if&amp;nbsp;visited_store = "No" then&amp;nbsp;visited_store_clean = 0;&lt;/P&gt;
&lt;P&gt;if&amp;nbsp;visited_store = "Yes" then&amp;nbsp;visited_store_clean = 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;P&gt;Does not seem to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help on how i can select rows with "No", missing value ( . ) and numeric values to 0, while "Yes" to 1?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the &amp;lt;&amp;gt; to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 15:36:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dealing-with-non-numeric-and-Missing-Value/m-p/670151#M201131</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-17T15:36:23Z</dc:date>
    </item>
  </channel>
</rss>

