<?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: Find and Replace - changing &amp;amp;quot;unknown&amp;amp;quot; to missing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750527#M236093</link>
    <description>&lt;P&gt;Doesn't the format option just change how the data is presented and not how it is stored? Would that mess up any future logistic regression analyses or anything else?&lt;/P&gt;</description>
    <pubDate>Fri, 25 Jun 2021 18:27:11 GMT</pubDate>
    <dc:creator>vanarsdale2</dc:creator>
    <dc:date>2021-06-25T18:27:11Z</dc:date>
    <item>
      <title>Find and Replace - changing &amp;quot;unknown&amp;quot; to missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750519#M236085</link>
      <description>&lt;P&gt;I have 291 "dichotomous" variables, Yes/No. Instead of ' ' [missing] all the missing values are recorded as "unknown".&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know I can use if/then sub-setting to set "Unknown" to " ", but I do not want to have to manually enter all 291 variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was thinking something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set trim;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if _all_ = "Unknown" then put " ";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I can't quite figure out what the code would be.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jun 2021 18:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750519#M236085</guid>
      <dc:creator>vanarsdale2</dc:creator>
      <dc:date>2021-06-25T18:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace - changing &amp;quot;unknown&amp;quot; to missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750520#M236086</link>
      <description>&lt;P&gt;So you have 291 character variables or length $7 (or longer)?&lt;/P&gt;
&lt;P&gt;Why not use a format?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  value $ynunk 'Yes'='Yes' 'No'='No' 'unknown',' '=' ' other='Invalid' ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use that format with your 291 variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
  tables var1-var291;
  format var1-var291 $ynunk. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Jun 2021 18:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750520#M236086</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-25T18:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace - changing &amp;quot;unknown&amp;quot; to missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750522#M236088</link>
      <description>&lt;P&gt;Here's a tutorial on using Arrays in SAS&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-arrays/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-arrays/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need an array instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set trim;

array _vars2recode(*) &amp;lt;list of variables&amp;gt;;

do i=1 to dim(_vars2recode);
    if _vars2recode(i) = 'Unknown' then _vars2recode(i) = .;
end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is a reference that illustrates how to refer to variables and datasets in a short cut list, so you don't have to list them 1 by 1 for the array list:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/387361"&gt;@vanarsdale2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have 291 "dichotomous" variables, Yes/No. Instead of ' ' [missing] all the missing values are recorded as "unknown".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know I can use if/then sub-setting to set "Unknown" to " ", but I do not want to have to manually enter all 291 variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was thinking something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set trim;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if _all_ = "Unknown" then put " ";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but I can't quite figure out what the code would be.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jun 2021 18:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750522#M236088</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-25T18:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace - changing &amp;quot;unknown&amp;quot; to missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750527#M236093</link>
      <description>&lt;P&gt;Doesn't the format option just change how the data is presented and not how it is stored? Would that mess up any future logistic regression analyses or anything else?&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jun 2021 18:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750527#M236093</guid>
      <dc:creator>vanarsdale2</dc:creator>
      <dc:date>2021-06-25T18:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace - changing &amp;quot;unknown&amp;quot; to missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750529#M236094</link>
      <description>&lt;P&gt;So you are saying I would be able to use the&amp;nbsp; _All_&amp;nbsp; keyword in an array? Because I was trying but couldn't with the subsetting&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jun 2021 18:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750529#M236094</guid>
      <dc:creator>vanarsdale2</dc:creator>
      <dc:date>2021-06-25T18:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace - changing &amp;quot;unknown&amp;quot; to missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750540#M236099</link>
      <description>&lt;P&gt;Arrays cannot mix numeric and character variables. So you can only use _ALL_ variable list in an array if your data step has only defined one type of variable (all numeric or all character).&amp;nbsp; You could use _CHARACTER_ variable list if you wanted.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  array _c _character_;
  do over _c;
    if upcase(_c)='UNKNOWN' then _c=' ';
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Jun 2021 18:58:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750540#M236099</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-25T18:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace - changing &amp;quot;unknown&amp;quot; to missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750541#M236100</link>
      <description>&lt;P&gt;Most PROCS will use the formatted values when creating groups.&amp;nbsp; Try it with your logistic regression.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jun 2021 18:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750541#M236100</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-25T18:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace - changing &amp;quot;unknown&amp;quot; to missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750544#M236102</link>
      <description>SQL doesn't aggregate by formats but beyond that most SAS procedures treat the formatted values as a single group. &lt;BR /&gt;</description>
      <pubDate>Fri, 25 Jun 2021 19:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-Replace-changing-amp-quot-unknown-amp-quot-to-missing/m-p/750544#M236102</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-25T19:48:43Z</dc:date>
    </item>
  </channel>
</rss>

