<?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: Checking a Range of Variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/929998#M365903</link>
    <description>&lt;P&gt;Awesome! Thank you so much!&lt;/P&gt;</description>
    <pubDate>Tue, 28 May 2024 21:53:13 GMT</pubDate>
    <dc:creator>sassy_seb</dc:creator>
    <dc:date>2024-05-28T21:53:13Z</dc:date>
    <item>
      <title>Checking a Range of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/929993#M365899</link>
      <description>&lt;P&gt;Hello, I was wondering if there was a way to check a range of variables to see if any are equal to a certain value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data checks;
	input check_1 $ check_2 $ check_3 $ check_4 $;
	datalines;
    Checked Unchecked Unchecked Unchecked
    Unchecked Unchecked Unchecked Unchecked 
    Unchecked Checked Unchecked Unchecked      
    ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Like for the above code, is there a way for me to test each line, and if any of the check_# variables equal to 'Checked' and save it to a new variable?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 20:58:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/929993#M365899</guid>
      <dc:creator>sassy_seb</dc:creator>
      <dc:date>2024-05-28T20:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Checking a Range of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/929996#M365901</link>
      <description>&lt;P&gt;Please double check that your data step creates the values you expect. The input statement you used only had 8 characters for the values which meant values of "Unchecke" were in the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are two functions that may be what you are looking for WHICHC for character values and WHICHN for numereric values. The function will return the position number of the first found match or 0 if not found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data checks;
	input check_1 :$10. check_2 :$10. check_3 :$10. check_4 :$10.;
   result = whichc('Checked',of check_1 - check_4);
datalines;
Checked Unchecked Unchecked Unchecked
Unchecked Unchecked Unchecked Unchecked 
Unchecked Checked Unchecked Unchecked 
;
run;&lt;/PRE&gt;
&lt;P&gt;You did not indicate exactly what was to be stored in then new variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 21:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/929996#M365901</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-05-28T21:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Checking a Range of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/929998#M365903</link>
      <description>&lt;P&gt;Awesome! Thank you so much!&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 21:53:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/929998#M365903</guid>
      <dc:creator>sassy_seb</dc:creator>
      <dc:date>2024-05-28T21:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: Checking a Range of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/929999#M365904</link>
      <description>&lt;P&gt;What I had in mind was basically storing either True or False if Checked was in the range. But I think I can make my problem work with having result be greater than 0.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 21:55:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/929999#M365904</guid>
      <dc:creator>sassy_seb</dc:creator>
      <dc:date>2024-05-28T21:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Checking a Range of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/930000#M365905</link>
      <description>&lt;P&gt;SAS will actually treat any numeric value other than 1 as "true" but this code may be more helpful:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;result = ( whichc('Checked',of check_1 - check_4) &amp;gt; 0);&lt;/PRE&gt;
&lt;P&gt;The () around every thing will force a logical comparison and return 1 for true if found and 0 for false.&lt;/P&gt;
&lt;P&gt;Strongly recommend leaving it as numeric 1 and 0 as that is much easier to deal with than actual "True" or "False" values. You can use a custom format to display text of True/False if needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When it comes to reporting if you SUM a numeric 1/0 coded value then the total is the number "true", MEAN is the percent true a decimal i.e. .75 = 75% true. There are a few other tricks available as well but these two work will with Proc Report or Tabulate for nice reports.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 22:12:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/930000#M365905</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-05-28T22:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Checking a Range of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/930001#M365906</link>
      <description>&lt;P&gt;You can convert "greater than 0" to a value of 1, with 1 indicating true and 0 indicating false.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 22:13:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/930001#M365906</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-05-28T22:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: Checking a Range of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/930005#M365909</link>
      <description>&lt;PRE&gt;data checks;
	input check_1 :$10. check_2 :$10. check_3 :$10. check_4 :$10.;
  array x{*} $ check_1 - check_4;
   result = 'Checked' in x;
datalines;
Checked Unchecked Unchecked Unchecked
Unchecked Unchecked Unchecked Unchecked 
Unchecked Checked Unchecked Unchecked 
;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 May 2024 01:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Checking-a-Range-of-Variables/m-p/930005#M365909</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-05-29T01:16:26Z</dc:date>
    </item>
  </channel>
</rss>

