<?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: Duplicate variable names after PROC SUMMARY? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Duplicate-variable-names-after-PROC-SUMMARY/m-p/234226#M54902</link>
    <description>&lt;P&gt;Yes, that is correct. &amp;nbsp;Column names have to be unique within a dataset. &amp;nbsp;Column labels can be anything you want.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Nov 2015 16:28:52 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-11-11T16:28:52Z</dc:date>
    <item>
      <title>Duplicate variable names after PROC SUMMARY?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Duplicate-variable-names-after-PROC-SUMMARY/m-p/234208#M54896</link>
      <description>&lt;P&gt;I have a dataset (let's calll it "OLDDATA") with two variables, "Var1" and "Var2". I am trying to create a new dataset ("NEWDATA"), with Var1, Var2, and a third variable called Var3. Var3 is to be calculated by summing up all values in Var1 and multiplying each value in Var2 by this figure. I was told somewhere that the way to do it is as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc summary data = sasdata.olddata;
var var1;
output out=column1_summary sum=total_var1;
run;

data sasdata.newdata;
set sasdata.olddata;
if _n_=1 then set column1_summary;
var3 = var2 * total_var1;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code runs without errors and produces the Var3 variable I expect. However, the resulting dataset, NEWDATA, has &lt;EM&gt;&lt;STRONG&gt;two columns named Var1&lt;/STRONG&gt;&lt;/EM&gt;, one from OLDDATA and the other populated exclusively by the output of PROC SUMMARY, i.e., that same value for every observation. I feel that having duplicate column names would not be helpful in later calculations. What is the syntax for suppressing the second Var1 column, or giving it some other name to avoid confusion?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 15:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Duplicate-variable-names-after-PROC-SUMMARY/m-p/234208#M54896</guid>
      <dc:creator>dvtarasov</dc:creator>
      <dc:date>2015-11-11T15:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate variable names after PROC SUMMARY?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Duplicate-variable-names-after-PROC-SUMMARY/m-p/234210#M54897</link>
      <description>&lt;P&gt;There are&amp;nbsp;&lt;U&gt;not&lt;/U&gt; two variables with the same name in any dataset, as the SAS system does not allow this. &amp;nbsp;What you have is two variables which have the same&amp;nbsp;&lt;U&gt;label&lt;/U&gt;. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run a proc contents and look at varname and varlabel, label will be the same, name will not. &amp;nbsp;It you still think it does, post the output of the proc contents.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 15:22:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Duplicate-variable-names-after-PROC-SUMMARY/m-p/234210#M54897</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-11T15:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate variable names after PROC SUMMARY?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Duplicate-variable-names-after-PROC-SUMMARY/m-p/234217#M54898</link>
      <description>I knew the system wouldn't allow duplicate names, so that, too, surprised me. Is it safe, then, to perform a calculation that calls my original Var1 by name--the system won't mix it up with the other variable that it labeled Var1?</description>
      <pubDate>Wed, 11 Nov 2015 16:08:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Duplicate-variable-names-after-PROC-SUMMARY/m-p/234217#M54898</guid>
      <dc:creator>dvtarasov</dc:creator>
      <dc:date>2015-11-11T16:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate variable names after PROC SUMMARY?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Duplicate-variable-names-after-PROC-SUMMARY/m-p/234220#M54899</link>
      <description>&lt;P&gt;Without running the code, I can't think off the top of my head, but from memory, the original variable remains, and new variables are created with an additional prefix/suffix (you can probably alter that as well through options). &amp;nbsp;Just open the dataset, and go up to (assuming you use SAS not UE or VA or something) View-&amp;gt;Column Names, and you will see what each variable is called.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 16:13:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Duplicate-variable-names-after-PROC-SUMMARY/m-p/234220#M54899</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-11T16:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate variable names after PROC SUMMARY?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Duplicate-variable-names-after-PROC-SUMMARY/m-p/234225#M54901</link>
      <description>&lt;P&gt;You are right. I ran PROC CONTENTS on the resulting dataset and saw that, while labels are the same, names are not. Am I right, then, that it does not matter if labels are the same as long as names are different?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 16:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Duplicate-variable-names-after-PROC-SUMMARY/m-p/234225#M54901</guid>
      <dc:creator>dvtarasov</dc:creator>
      <dc:date>2015-11-11T16:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate variable names after PROC SUMMARY?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Duplicate-variable-names-after-PROC-SUMMARY/m-p/234226#M54902</link>
      <description>&lt;P&gt;Yes, that is correct. &amp;nbsp;Column names have to be unique within a dataset. &amp;nbsp;Column labels can be anything you want.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 16:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Duplicate-variable-names-after-PROC-SUMMARY/m-p/234226#M54902</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-11T16:28:52Z</dc:date>
    </item>
  </channel>
</rss>

