<?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: How do I add the same suffix to every variable name in a dataset? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918249#M361708</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/102348"&gt;@sas21&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n0c1y14wyd3u7yn1dmfcpaejllsn.htm" target="_blank" rel="noopener"&gt;PROC COMPARE&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n0r7339gsbewpwn1nq3fqxlcoxau.htm" target="_blank" rel="noopener"&gt;BY&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p0mibcdoex15m9n1ed7gi2itiy9i.htm" target="_blank" rel="noopener"&gt;ID&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1xrf09nbjnxjzn1kdmbcajf1s1v.htm" target="_blank" rel="noopener"&gt;VAR&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p04tys9thfky3ln1ayl9vphsdt63.htm" target="_blank" rel="noopener"&gt;WITH&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p04tys9thfky3ln1ayl9vphsdt63.htm" target="_blank" rel="noopener"&gt;WITH&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Compare variables of different names&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, according to this example, it says the variables need to have different names.&amp;nbsp; And as of now, the two datasets I want to compare have the exact same variable names, which is why I thought it would be better to change the variable names in one of them.&amp;nbsp; Or am I misinterpreting something?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can compare two data sets by ID with the same variable names without having to rename.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2024 16:22:29 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2024-02-28T16:22:29Z</dc:date>
    <item>
      <title>How do I add the same suffix to every variable name in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918131#M361667</link>
      <description>&lt;P&gt;I have a data set "compare_cohort" with the following variables....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp;COUNTRY&amp;nbsp; &amp;nbsp; &amp;nbsp; BRTHDT&amp;nbsp; DTHDTRACE ......etc it has a lot of variables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I want to make every variable name end in _new, so the new variable name would look like;&lt;/P&gt;&lt;P&gt;ID_NEW&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; COUNTRY_NEW&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BRTHDT_NEW&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DTHDT_NEW&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;RACE_NEW&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ETC....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Everything I am trying is adding it to the variable values and not the variable names themselves.&amp;nbsp; Any help is appreciated!&amp;nbsp; &amp;nbsp;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 21:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918131#M361667</guid>
      <dc:creator>sas21</dc:creator>
      <dc:date>2024-02-27T21:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add the same suffix to every variable name in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918133#M361669</link>
      <description>&lt;P&gt;Here's a quick way using the dictionary tables to get the list of the variable names, and create the new name using the CATT() function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC DATASETS will update the data with the new variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*create sample data set;
data class;
set sashelp.class;
run;


proc sql noprint;
select catx("=", name, catt(name, "_NEW")) /*creates oldvariable = newvariable for rename statement*/
into :rename_list
separated by " "
from sashelp.vcolumn
where libname='WORK' /*replace with your library, or WORK*/
and memname='CLASS' /*replace with data set name - note that it must be upper case, same as libname*/
;
quit;

*check the variable rename list in the log;
%put &amp;amp;rename_list;

*rename the variables without rewriting the full data set;
proc datasets library=work nodetails nolist;
modify class;
rename &amp;amp;rename_list;
run; quit;

*check output;
proc print data=class noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/102348"&gt;@sas21&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a data set "compare_cohort" with the following variables....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp;COUNTRY&amp;nbsp; &amp;nbsp; &amp;nbsp; BRTHDT&amp;nbsp; DTHDTRACE ......etc it has a lot of variables&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and I want to make every variable name end in _new, so the new variable name would look like;&lt;/P&gt;
&lt;P&gt;ID_NEW&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; COUNTRY_NEW&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BRTHDT_NEW&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DTHDT_NEW&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;RACE_NEW&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ETC....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Everything I am trying is adding it to the variable values and not the variable names themselves.&amp;nbsp; Any help is appreciated!&amp;nbsp; &amp;nbsp;Thank you so much!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 22:14:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918133#M361669</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-02-27T22:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add the same suffix to every variable name in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918134#M361670</link>
      <description>&lt;P&gt;So do you also have a dataset where you don't want the _NEW on these exact same variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, then I think there's a better way to go. Just vertically join the data sets (SET command in a data step) and create a variable to indicate where or not the data is the NEW data or the "old" data, for lack of a better term. No renaming needed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Analysis is usually much easier with the data arranged as described above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data combined;
    set old_data_set_name new_data_set_name indsname=indsname;
    dsname=indsname;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How easy is that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But please describe the problem further, why are you doing this and what will you do after you create this data set? Context is everything and you have given us no context; and in many contexts arranging the data the way you describe is not the easiest thing to do, and it can make the next steps harder.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 01:08:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918134#M361670</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-02-28T01:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add the same suffix to every variable name in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918136#M361671</link>
      <description>&lt;P&gt;Have you verified that all of your existing variables are short enough names that adding 4 characters will not violate SAS variable naming rules? If you have a variable that already has 32 characters in the name you cannot add any. So what should be done in this case. Or if any name longer than 28 you can only add to a total of 32. So are you going to want variables that end in _NE or _N ?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 22:54:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918136#M361671</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-02-27T22:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add the same suffix to every variable name in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918216#M361694</link>
      <description>&lt;P&gt;I have two of the same datasets that contain the exact same variable names, but they are different in what they contain.&amp;nbsp; I need to compare age, race and other demographic variables.&amp;nbsp; I wanted to change the the variable names in one of the datasets so I could tell the two apart, and I am not sure if the variables need to be different when using PROC COMPARE or if it will throw an error.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 13:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918216#M361694</guid>
      <dc:creator>sas21</dc:creator>
      <dc:date>2024-02-28T13:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add the same suffix to every variable name in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918218#M361695</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/102348"&gt;@sas21&lt;/a&gt;&amp;nbsp; It's actually a bit less coding if the variable names are the same. If that's not the case then you need to use the VAR and WITH statements to instruct Proc Compare to use which variables from the one datasets for comparison with which variable from the other dataset. It's all documented&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1nwxbchh5hpu1n1h28kmici2awd.htm" target="_self"&gt;COMPARE Procedure&lt;/A&gt;&amp;nbsp;examples included.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 13:59:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918218#M361695</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-28T13:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add the same suffix to every variable name in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918233#M361698</link>
      <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n0c1y14wyd3u7yn1dmfcpaejllsn.htm" target="_blank" rel="noopener"&gt;PROC COMPARE&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n0r7339gsbewpwn1nq3fqxlcoxau.htm" target="_blank" rel="noopener"&gt;BY&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p0mibcdoex15m9n1ed7gi2itiy9i.htm" target="_blank" rel="noopener"&gt;ID&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1xrf09nbjnxjzn1kdmbcajf1s1v.htm" target="_blank" rel="noopener"&gt;VAR&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p04tys9thfky3ln1ayl9vphsdt63.htm" target="_blank" rel="noopener"&gt;WITH&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p04tys9thfky3ln1ayl9vphsdt63.htm" target="_blank" rel="noopener"&gt;WITH&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Compare variables of different names&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, according to this example, it says the variables need to have different names.&amp;nbsp; And as of now, the two datasets I want to compare have the exact same variable names, which is why I thought it would be better to change the variable names in one of them.&amp;nbsp; Or am I misinterpreting something?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 15:24:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918233#M361698</guid>
      <dc:creator>sas21</dc:creator>
      <dc:date>2024-02-28T15:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add the same suffix to every variable name in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918236#M361700</link>
      <description>Thank you for the reminder! I just double checked and I should be good!</description>
      <pubDate>Wed, 28 Feb 2024 15:29:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918236#M361700</guid>
      <dc:creator>sas21</dc:creator>
      <dc:date>2024-02-28T15:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add the same suffix to every variable name in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918238#M361702</link>
      <description>&lt;P&gt;In this example, the variable in both data sets has the name YEAR&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p1k00d45g03uv8n1bfx3d20breg6.htm" target="_self"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p1k00d45g03uv8n1bfx3d20breg6.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a great example of why you should tell us, in your first post on a subject, what you are doing and why you are doing it, rather than focusing strictly on coding (how to add suffixes to a variable name).&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 15:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918238#M361702</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-02-28T15:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add the same suffix to every variable name in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918240#M361703</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/102348"&gt;@sas21&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have two of the same datasets that contain the exact same variable names, but they are different in what they contain.&amp;nbsp; I need to compare age, race and other demographic variables.&amp;nbsp; I wanted to change the the variable names in one of the datasets so I could tell the two apart, and I am not sure if the variables need to be different when using PROC COMPARE or if it will throw an error.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What do you mean by "compare"? SAS has a procedure named Compare that is used to examine entire data sets.&lt;/P&gt;
&lt;P&gt;If you actually mean something more like "examine differences in results of statistical tests" or distributions of value you are &lt;STRONG&gt;way&lt;/STRONG&gt; better off providing an additional variable to indicate the new/old data set and using that as class or grouping variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An example you can run where I compare the height and weight of students by SEX in a data set using a TTest:&lt;/P&gt;
&lt;PRE&gt;proc ttest data=sashelp.class;
   class sex;
   var height weight;
run;&lt;/PRE&gt;
&lt;P&gt;Or using Sex to see the distribution of another variable such as AGE:&lt;/P&gt;
&lt;PRE&gt;Proc freq data=sashelp.class;
   tables sex*age;
run;&lt;/PRE&gt;
&lt;P&gt;If you do something like the following then a New data set with all the observations will be created and a variable SOURCE will have the library and data set name of each of the source data sets and can be used as a grouping variable for any analysis.&lt;/P&gt;
&lt;PRE&gt;data new;
   set dataset1   dataset2 indsname=sourcename;
   source=sourcename;
run;&lt;/PRE&gt;
&lt;P&gt;Caution: if any of the variables with the same name are of different types you will get an error and indicates your "comparison" would be problematic at best involving those variables. If the lengths of a character variable differ in the two sets, again a problem with "comparison", you will see a note about possible truncation and loss of data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 15:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918240#M361703</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-02-28T15:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add the same suffix to every variable name in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918249#M361708</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/102348"&gt;@sas21&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n0c1y14wyd3u7yn1dmfcpaejllsn.htm" target="_blank" rel="noopener"&gt;PROC COMPARE&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n0r7339gsbewpwn1nq3fqxlcoxau.htm" target="_blank" rel="noopener"&gt;BY&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p0mibcdoex15m9n1ed7gi2itiy9i.htm" target="_blank" rel="noopener"&gt;ID&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1xrf09nbjnxjzn1kdmbcajf1s1v.htm" target="_blank" rel="noopener"&gt;VAR&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p04tys9thfky3ln1ayl9vphsdt63.htm" target="_blank" rel="noopener"&gt;WITH&lt;/A&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p04tys9thfky3ln1ayl9vphsdt63.htm" target="_blank" rel="noopener"&gt;WITH&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Compare variables of different names&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, according to this example, it says the variables need to have different names.&amp;nbsp; And as of now, the two datasets I want to compare have the exact same variable names, which is why I thought it would be better to change the variable names in one of them.&amp;nbsp; Or am I misinterpreting something?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can compare two data sets by ID with the same variable names without having to rename.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 16:22:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918249#M361708</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-02-28T16:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add the same suffix to every variable name in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918346#M361747</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/102348"&gt;@sas21&lt;/a&gt;&amp;nbsp;Yes, you must be misinterpreting something.&lt;/P&gt;
&lt;P&gt;- The VAR statement allows you to define which variables to use for the comparison. If you don't use it then all variables in the tables will get used.&lt;/P&gt;
&lt;P&gt;- The WITH statement allows you to compare variables with different names. You can use the VAR statement for a list of variables in the base table and WITH for the list of variables in the compare table. Proc compare will then just use the names positionally and compare the first variable from VAR with the first variable from WITH, 2nd with 2nd, 3rd with 3rd etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below working sample code for a case where the variables have the same name in both source tables. Just run it and see what happens.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.class1 work.class2;
  set sashelp.class;
  output work.class1;
  if _n_=5 then
    do;
      age=9;
      height=52.7;
    end;
  if _n_=9 then
    do;
      sex='x';
    end;
  output work.class2;
run;

proc compare base=work.class1 compare=work.class2;
/* var age height;*/
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Feb 2024 00:44:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-the-same-suffix-to-every-variable-name-in-a-dataset/m-p/918346#M361747</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-29T00:44:43Z</dc:date>
    </item>
  </channel>
</rss>

