<?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: Copy values of one column to another column in same dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Copy-values-of-one-column-to-another-column-in-same-dataset/m-p/643457#M192029</link>
    <description>&lt;P&gt;Hi &lt;A class="trigger-hovercard" style="color: #999999;" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/325666" target="_blank"&gt;DataYes&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;You are getting this because your ID variable on your data set HAVE has length of 1. If you assign long enough length it will work. For example, the following data step will work fine:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   length ID $3;
   set have;
   ID=ID_2;
   drop ID_2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can do it this way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have (drop=ID rename=(ID_2=ID));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you need a certain variable order on your data set you can achieve it with the retain statement placed before set statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   retain Name ID address;
   set have (drop=ID rename=(ID_2=ID));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Apr 2020 02:51:26 GMT</pubDate>
    <dc:creator>LeonidBatkhan</dc:creator>
    <dc:date>2020-04-28T02:51:26Z</dc:date>
    <item>
      <title>Copy values of one column to another column in same dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-values-of-one-column-to-another-column-in-same-dataset/m-p/643454#M192028</link>
      <description>&lt;P&gt;Hello, i have a data set which i created in a work library. i want to drop one column and also copy the values of dropped column in another column which is blank. how do i do that?&lt;/P&gt;&lt;P&gt;here is an example.&lt;/P&gt;&lt;P&gt;Suppose i have a dataset which has 4 columns:&lt;/P&gt;&lt;P&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; address&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ID_2&lt;/P&gt;&lt;P&gt;Sam&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; xyz&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;123&lt;/P&gt;&lt;P&gt;Bob&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;&amp;nbsp; abc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 456&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to be able to modify the dataset to drop the column "ID_2" and move the values from the column "123" and "456" to "ID"&lt;/P&gt;&lt;P&gt;how can i acheive it using proc sql?&lt;/P&gt;&lt;P&gt;here is what i have done so far&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;ID=ID_2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the issue with this stateent is that it only captures the first letter of the column "ID_2". so using the above example, when i run the code mentioned above, i get:&lt;/P&gt;&lt;P&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp; ID&amp;nbsp;&amp;nbsp; Address&amp;nbsp;&amp;nbsp;&amp;nbsp; ID_2&lt;/P&gt;&lt;P&gt;SAM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xyz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&lt;/P&gt;&lt;P&gt;Boc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; abc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 456&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please guide&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;here is&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 02:06:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-values-of-one-column-to-another-column-in-same-dataset/m-p/643454#M192028</guid>
      <dc:creator>DataYes</dc:creator>
      <dc:date>2020-04-28T02:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Copy values of one column to another column in same dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-values-of-one-column-to-another-column-in-same-dataset/m-p/643457#M192029</link>
      <description>&lt;P&gt;Hi &lt;A class="trigger-hovercard" style="color: #999999;" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/325666" target="_blank"&gt;DataYes&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;You are getting this because your ID variable on your data set HAVE has length of 1. If you assign long enough length it will work. For example, the following data step will work fine:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   length ID $3;
   set have;
   ID=ID_2;
   drop ID_2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can do it this way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have (drop=ID rename=(ID_2=ID));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you need a certain variable order on your data set you can achieve it with the retain statement placed before set statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   retain Name ID address;
   set have (drop=ID rename=(ID_2=ID));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 02:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-values-of-one-column-to-another-column-in-same-dataset/m-p/643457#M192029</guid>
      <dc:creator>LeonidBatkhan</dc:creator>
      <dc:date>2020-04-28T02:51:26Z</dc:date>
    </item>
  </channel>
</rss>

