<?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: Creating a list of specific variables involved in an issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-list-of-specific-variables-involved-in-an-issue/m-p/740893#M231527</link>
    <description>Thank you, that's exactly what I was looking for &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Wed, 12 May 2021 18:34:58 GMT</pubDate>
    <dc:creator>Walternate</dc:creator>
    <dc:date>2021-05-12T18:34:58Z</dc:date>
    <item>
      <title>Creating a list of specific variables involved in an issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-list-of-specific-variables-involved-in-an-issue/m-p/740879#M231518</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data quality check program, which parses records in a data file for various data quality issues. If an issue is found, the program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Assigns a sequential issue number&lt;/P&gt;
&lt;P&gt;2. Outputs the record&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a few checks in which a large subset of variables (say 20 variables) is checked for a given issue. The issue could occur in zero, one, two, or up to twenty (all) of the variables and there's no way to distinguish. So I want to add a column which will say exactly which variable(s) is having an issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example of input data, in which we are looking for the issue of does not equal 1 in v1 through v10:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;input v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 ;&lt;BR /&gt;cards;&lt;BR /&gt;1 1 1 1 1 1 1 1 1 1&amp;nbsp;&lt;BR /&gt;0 1 1 1 1 1 1 1 1 1&amp;nbsp;&lt;BR /&gt;1 1 1 1 1 1 1 1 1 0&amp;nbsp;&lt;BR /&gt;1 1 1 1 0 1 1 1 1 1&amp;nbsp;&lt;BR /&gt;0 0 1 1 1 1 1 1 1 1&amp;nbsp;&lt;BR /&gt;1 1 1 0 1 1 1 0 1 1&amp;nbsp;&lt;BR /&gt;1 0 1 1 1 0 0 1 1 1&amp;nbsp;&lt;BR /&gt;0 0 0 0 1 1 1 1 1 1&amp;nbsp;&lt;BR /&gt;1 1 1 1 1 0 0 0 0 0&amp;nbsp;&lt;BR /&gt;1 0 1 0 1 0 1 0 1 0&amp;nbsp;&lt;BR /&gt;0 1 0 1 0 1 0 1 0 1&amp;nbsp;&lt;BR /&gt;1 1 0 1 0 0 0 1 0 0&amp;nbsp;&lt;BR /&gt;0 0 1 0 0 1 0 1 0 0&amp;nbsp;&lt;BR /&gt;1 0 0 0 0 0 0 0 0 1&amp;nbsp;&lt;BR /&gt;0 0 0 0 0 1 0 0 0 0&amp;nbsp;&lt;BR /&gt;0 0 0 0 0 0 0 0 0 0&amp;nbsp;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output data would have one row per record that has an issue (one of the vars in v1-v10 not equal to 1), including an issue number and a column which summarizes which variables specifically were flagged as having issues:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;issue_number&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;vars_with_issues&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;v1&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;v10&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;v5&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;v1, v2&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; v4, v8&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Etc. So:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. There should be one row of output per row WITH ISSUES in the input file&lt;/P&gt;
&lt;P&gt;2. Each row in the output file should have an issue number assigned (the same one, since we are only talking about one issue)&lt;/P&gt;
&lt;P&gt;3. Each row in the output file should have a column which summarizes which specific variables of v1-v10 were actually flagged as having an issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm good on 1 and 2, but have not been able to figure out how to set up #3.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help is much appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 17:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-list-of-specific-variables-involved-in-an-issue/m-p/740879#M231518</guid>
      <dc:creator>Walternate</dc:creator>
      <dc:date>2021-05-12T17:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a list of specific variables involved in an issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-list-of-specific-variables-involved-in-an-issue/m-p/740892#M231526</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37814"&gt;@Walternate&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(where=(vars_with_issues) drop=i v1-v10);
set test;
array a[*] v1-v10;
retain issue_number 1; /* issue "value ≠ 1" */
length vars_with_issues $100;
do i=1 to dim(a);
  if a[i] ne 1 then vars_with_issues=catx(', ',vars_with_issues,vname(a[i]));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Make sure that the length of &lt;FONT face="courier new,courier"&gt;vars_with_issues&lt;/FONT&gt;&amp;nbsp;(100 in the example) is large enough for your real data. Different types of &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrcon/p0wphcpsfgx6o7n1sjtqzizp1n39.htm" target="_blank" rel="noopener"&gt;variable lists&lt;/A&gt;&amp;nbsp;(or an explicit list of variable names, possibly created dynamically) could be used in the array definition.&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 18:14:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-list-of-specific-variables-involved-in-an-issue/m-p/740892#M231526</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-05-12T18:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a list of specific variables involved in an issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-list-of-specific-variables-involved-in-an-issue/m-p/740893#M231527</link>
      <description>Thank you, that's exactly what I was looking for &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 12 May 2021 18:34:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-list-of-specific-variables-involved-in-an-issue/m-p/740893#M231527</guid>
      <dc:creator>Walternate</dc:creator>
      <dc:date>2021-05-12T18:34:58Z</dc:date>
    </item>
  </channel>
</rss>

