<?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: a single if-then statement that applies to all variables in the dataset? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/a-single-if-then-statement-that-applies-to-all-variables-in-the/m-p/725636#M225428</link>
    <description>&lt;P&gt;I assume you have all numeric variables, as &amp;lt;0 doesn't apply to character variables. So ... the data step method you need is called an ARRAY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    array x _numeric_;
    do i=1 to dim(x);
        if x(i)&amp;lt;0 then call missing(x(i));
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 11 Mar 2021 21:28:15 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-03-11T21:28:15Z</dc:date>
    <item>
      <title>a single if-then statement that applies to all variables in the dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/a-single-if-then-statement-that-applies-to-all-variables-in-the/m-p/725634#M225426</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to code all variables in my dataset so that any observations less than 0 are coded as missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried something like this, but I guess the "_ALL_" trick only works in certain situations and doesn't work here?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if _ALL_ &amp;lt; 0 then _ALL_=.;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know of an easier way to get SAS to perform this data step all at once, without me having to list each variable on their own on a separate line?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 21:23:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/a-single-if-then-statement-that-applies-to-all-variables-in-the/m-p/725634#M225426</guid>
      <dc:creator>kai_cody</dc:creator>
      <dc:date>2021-03-11T21:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: a single if-then statement that applies to all variables in the dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/a-single-if-then-statement-that-applies-to-all-variables-in-the/m-p/725636#M225428</link>
      <description>&lt;P&gt;I assume you have all numeric variables, as &amp;lt;0 doesn't apply to character variables. So ... the data step method you need is called an ARRAY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    array x _numeric_;
    do i=1 to dim(x);
        if x(i)&amp;lt;0 then call missing(x(i));
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Mar 2021 21:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/a-single-if-then-statement-that-applies-to-all-variables-in-the/m-p/725636#M225428</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-03-11T21:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: a single if-then statement that applies to all variables in the dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/a-single-if-then-statement-that-applies-to-all-variables-in-the/m-p/725649#M225437</link>
      <description>Your logic can also be reduced to the maximum of a series being less than 0. Note that rows of missing will evaluate as true and all will be set to missing, which is the same so a non-issue.  &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if max(of _numeric_) &amp;lt; 0 then call missing(of _numeric_);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Mar 2021 22:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/a-single-if-then-statement-that-applies-to-all-variables-in-the/m-p/725649#M225437</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-11T22:15:25Z</dc:date>
    </item>
  </channel>
</rss>

