<?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: Get names of variables with at least one changed value by program in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Get-names-of-variables-with-at-least-one-changed-value-by/m-p/729434#M226985</link>
    <description>&lt;P&gt;Building on &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, here's an example of how to output results that are different for some data sets using PROC COMPARE. You may need to tinker with some of the options here (if you only want the compare value, drop the outbase option) , but I think it shows what PROC COMPARE can do. It's a procedure I used heavily in a previous job. Edit: looking at your question again, I'm not sure if I totally answered the question. You want to know the value that differs and then return the variable name? It also assumes a sort, but you can avoid this with an ID statement instead of the BY statement, but it will send a warning about duplicate values if you have them in your data set. Also, if you want to see the report that PROC COMPARE produces, remove the NOPRINT option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id value;
datalines;
1 2
1 3
1 4
1 5
1 6
;

data have_2;
input id value;
datalines;
1 2
1 3
1 4
1 5
1 7
;

proc compare out = work.want outnoequal outbase outcomp noprint
	base = have
	compare = have_2;
	by id;
	var value;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Mar 2021 16:21:46 GMT</pubDate>
    <dc:creator>maguiremq</dc:creator>
    <dc:date>2021-03-26T16:21:46Z</dc:date>
    <item>
      <title>Get names of variables with at least one changed value by program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-names-of-variables-with-at-least-one-changed-value-by/m-p/729388#M226958</link>
      <description>&lt;P&gt;I have several large datasets that are iteratively processed by several sas programs, some of which I am not the primary programmer for.&amp;nbsp; I'm trying to brainstorm an easy data driven way to hook into those programs and record the names of variables with at least one changed observation (independent of sort order).&amp;nbsp; I'm hoping sas tracks this somewhere behind the scenes and I can write a macro to tap into it without placing too much of a burden on the other programmers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I currently can track input variables into each program, and I can track when new variables are being created by diffing proc summaries before and after the program is ran, but obviously checking for changed values is much harder and it would be very useful to track dependencies between these chains of programs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 14:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-names-of-variables-with-at-least-one-changed-value-by/m-p/729388#M226958</guid>
      <dc:creator>weg</dc:creator>
      <dc:date>2021-03-26T14:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Get names of variables with at least one changed value by program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-names-of-variables-with-at-least-one-changed-value-by/m-p/729417#M226974</link>
      <description>PROC SCAPROC when you run the full process is one method. &lt;BR /&gt;&lt;BR /&gt;PROC COMPARE is another method but a world of coding can't erase a lack of documentation.</description>
      <pubDate>Fri, 26 Mar 2021 15:18:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-names-of-variables-with-at-least-one-changed-value-by/m-p/729417#M226974</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-26T15:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: Get names of variables with at least one changed value by program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-names-of-variables-with-at-least-one-changed-value-by/m-p/729434#M226985</link>
      <description>&lt;P&gt;Building on &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, here's an example of how to output results that are different for some data sets using PROC COMPARE. You may need to tinker with some of the options here (if you only want the compare value, drop the outbase option) , but I think it shows what PROC COMPARE can do. It's a procedure I used heavily in a previous job. Edit: looking at your question again, I'm not sure if I totally answered the question. You want to know the value that differs and then return the variable name? It also assumes a sort, but you can avoid this with an ID statement instead of the BY statement, but it will send a warning about duplicate values if you have them in your data set. Also, if you want to see the report that PROC COMPARE produces, remove the NOPRINT option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id value;
datalines;
1 2
1 3
1 4
1 5
1 6
;

data have_2;
input id value;
datalines;
1 2
1 3
1 4
1 5
1 7
;

proc compare out = work.want outnoequal outbase outcomp noprint
	base = have
	compare = have_2;
	by id;
	var value;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 16:21:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-names-of-variables-with-at-least-one-changed-value-by/m-p/729434#M226985</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-03-26T16:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get names of variables with at least one changed value by program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-names-of-variables-with-at-least-one-changed-value-by/m-p/729447#M226989</link>
      <description>Thanks, this was useful, I think I can copy the datasets before a program is run and then compare before and after using this method with the ID for the keys</description>
      <pubDate>Fri, 26 Mar 2021 17:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-names-of-variables-with-at-least-one-changed-value-by/m-p/729447#M226989</guid>
      <dc:creator>weg</dc:creator>
      <dc:date>2021-03-26T17:22:48Z</dc:date>
    </item>
  </channel>
</rss>

