<?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 PROC COMPARE CHANGE _TYPE_ VARIABLE? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-CHANGE-TYPE-VARIABLE/m-p/927336#M364955</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have the below code which is part of larger code that will stop running the rest of the program if there is a difference in the proc compare. It is working okay but I am curious if there is a way to rename the _type_ variable that is created for the comparison. Right now it list BASE and COMPARE which is great but for a user that isn't aware I would like to rename to the actual file names. Is this possible?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JC411911_0-1715100668272.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96222iA8B4ECFAC0A6F4E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JC411911_0-1715100668272.png" alt="JC411911_0-1715100668272.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let diff_count = 0;

/* Compare the TO_TAX and FROM_TAX BUWfiles */
PROC COMPARE BASE=WORK.TO_TAX_MODIFIED brief transpose COMPARE=WORK.FROM_TAX_MODIFIED OUT=COMPARISON OUTBASE OUTCOMP OUTDIF LISTOBS OUTNOEQUAL BRIEFSUMMARY;
    VAR member_number account_number payer_id ;
    title 'COMPARING FILE SENT AND RECEIVED FROM';
RUN;

DATA _NULL_;
    SET COMPARISON END=eof;
    IF eof THEN CALL SYMPUT('diff_count', _N_);
RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 May 2024 16:53:04 GMT</pubDate>
    <dc:creator>JC411911</dc:creator>
    <dc:date>2024-05-07T16:53:04Z</dc:date>
    <item>
      <title>PROC COMPARE CHANGE _TYPE_ VARIABLE?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-CHANGE-TYPE-VARIABLE/m-p/927336#M364955</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have the below code which is part of larger code that will stop running the rest of the program if there is a difference in the proc compare. It is working okay but I am curious if there is a way to rename the _type_ variable that is created for the comparison. Right now it list BASE and COMPARE which is great but for a user that isn't aware I would like to rename to the actual file names. Is this possible?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JC411911_0-1715100668272.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96222iA8B4ECFAC0A6F4E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JC411911_0-1715100668272.png" alt="JC411911_0-1715100668272.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let diff_count = 0;

/* Compare the TO_TAX and FROM_TAX BUWfiles */
PROC COMPARE BASE=WORK.TO_TAX_MODIFIED brief transpose COMPARE=WORK.FROM_TAX_MODIFIED OUT=COMPARISON OUTBASE OUTCOMP OUTDIF LISTOBS OUTNOEQUAL BRIEFSUMMARY;
    VAR member_number account_number payer_id ;
    title 'COMPARING FILE SENT AND RECEIVED FROM';
RUN;

DATA _NULL_;
    SET COMPARISON END=eof;
    IF eof THEN CALL SYMPUT('diff_count', _N_);
RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2024 16:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-CHANGE-TYPE-VARIABLE/m-p/927336#M364955</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2024-05-07T16:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: PROC COMPARE CHANGE _TYPE_ VARIABLE?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-CHANGE-TYPE-VARIABLE/m-p/927338#M364956</link>
      <description>&lt;P&gt;Are asking how to make a COPY of the OUTPUT dataset from PROC COMPARE where you replace the values "BASE" and "COMPARE" in the variable _TYPE_ with the names of the datasets that were compared?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That should be simple, as long as you actually have the names.&amp;nbsp; In your example code the names are only in the CODE, they are not anywhere that a program could find them.&amp;nbsp; If you have the names in a macro variable for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let base=TO_TAX_MODIFIED ;
%let compare=FROM_TAX_MODIFIED ;
proc compare base=&amp;amp;base compare=&amp;amp;compare out=COMPARISON .....
...

data COMPARISON ;
  length _type_ $41 ;
  set COMPARISON ;
  if _type_="BASE" then _type_="&amp;amp;base";
  if _type_="COMPARE" then _type_="&amp;amp;compare";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 May 2024 17:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-CHANGE-TYPE-VARIABLE/m-p/927338#M364956</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-07T17:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: PROC COMPARE CHANGE _TYPE_ VARIABLE?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-CHANGE-TYPE-VARIABLE/m-p/927341#M364957</link>
      <description>&lt;P&gt;First, which data set is this?&lt;/P&gt;
&lt;P&gt;Are the "users" looking at the table view or a report generated from that data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Typically the response when related to "display a value" question is "use a format". Then either assign the format to the variable in a data set, which may have issues if you recreate the same format name, or use it to generate a report.&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;data work.class;
   set sashelp.class;
   if name = 'Alice' then sex='M';
run;

PROC COMPARE BASE=sashelp.class brief transpose COMPARE=work.class OUT=work.COMPARISON OUTBASE OUTCOMP OUTDIF LISTOBS OUTNOEQUAL BRIEFSUMMARY;
RUN;

proc format library=work;
value $compbase
'BASE'='Sashelp.class'
'COMPARE'='Work.Class'
;
run;

/* modify the report data set to use the format*/
proc datasets library=work nodetails;
   modify Comparison;
   format _type_ $compbase.;
   run;
quit;&lt;/PRE&gt;
&lt;P&gt;First make a data set with a difference to see the result.&lt;/P&gt;
&lt;P&gt;Create the output and format, then assign that format to the dataset.&lt;/P&gt;
&lt;P&gt;Or use a data step to add a variable with the name of the data set based on the value of _type_. The length of the _type_ variable is almost certainly going to be too short to accept many Library.datasetname values.&lt;/P&gt;
&lt;PRE&gt;data work.final;
   set work.comparison;
   length setname $ 41;
   setname = put(_type_,$compbase.);
run;

&lt;/PRE&gt;
&lt;P&gt;This will have values like DIF in the Setname values by default as there is nothing in the format definition to change that. Or use If/then/else instead of a format.&lt;/P&gt;
&lt;P&gt;The last may be preferred with shared data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2024 17:18:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-CHANGE-TYPE-VARIABLE/m-p/927341#M364957</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-05-07T17:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: PROC COMPARE CHANGE _TYPE_ VARIABLE?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-CHANGE-TYPE-VARIABLE/m-p/927345#M364958</link>
      <description>Thank you simple enough. That gives me what I was needing. I guess my though was doing it in the proc compare step but seems like the base and compare observations are standard thus the need to create a separate data step to rename. Thank you</description>
      <pubDate>Tue, 07 May 2024 18:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-CHANGE-TYPE-VARIABLE/m-p/927345#M364958</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2024-05-07T18:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: PROC COMPARE CHANGE _TYPE_ VARIABLE?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-CHANGE-TYPE-VARIABLE/m-p/927346#M364959</link>
      <description>Thank you, this process works!</description>
      <pubDate>Tue, 07 May 2024 18:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-COMPARE-CHANGE-TYPE-VARIABLE/m-p/927346#M364959</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2024-05-07T18:35:04Z</dc:date>
    </item>
  </channel>
</rss>

