<?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 column from one dataset to another in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182214#M265251</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do I need to install the SAS System Viewer? &lt;/P&gt;&lt;P&gt;You copied only first 6 values, but If I do this for the whole dataset then there will be 264 values. Isn't it too much?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Feb 2014 21:27:08 GMT</pubDate>
    <dc:creator>AbuChowdhury</dc:creator>
    <dc:date>2014-02-21T21:27:08Z</dc:date>
    <item>
      <title>Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182200#M265237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to copy one column from one dataset to another dataset. Moreover, I need to do the same task many times (say I need to copy column1 from datase_1 to dataset_a, column1 from dataset_2 to dataset_b, and so on. How can I do this task? Should I use macro such as %macro, %copy etc?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Further, I need to subtract that copied column from every variable in the dataset. Say, dataset_a has variables: date, Firm1, Firm2,&amp;nbsp; … Firm100. Now column1 from dataset_1 will be copied to dataset_a. So dataset_a will look like: Date, Firm1, Firm2, … Firm100, column1. Now column1 will have to be subtracted from Firm1, Firm2 , … Firm100. In this way, column1 from dataset_2 will have to copied to dataset_b and that copied variable will have to be subtracted from other variables in dataset_b.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 11:29:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182200#M265237</guid>
      <dc:creator>AbuChowdhury</dc:creator>
      <dc:date>2014-02-21T11:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182201#M265238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does the column you want to copy always have the same number of observations as the data set you want to copy to. If not then you'll need to specify what should happen when there is a difference in observation count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A simple example of a macro where the observations are the same would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data class(rename=(age=years));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set sashelp.class;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro addcol(ds1,col,ds2,newds);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; data &amp;amp;newds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &amp;amp;ds2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &amp;amp;ds1(keep=&amp;amp;col);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend addcol;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%addcol(class,years,sashelp.class,class2);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 12:17:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182201#M265238</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2014-02-21T12:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182202#M265239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"Copy a column" is not a normal data management activity.&amp;nbsp; From your later description is looks like you want to merge on a new variable based on values of your key variable DATE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; merge old new (keep=date diff) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by date;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; array firms firm1-firm100 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do over firms; firms=firms - diff; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 12:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182202#M265239</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-21T12:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182203#M265240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;SPAN style="font-style: inherit;"&gt;It's not working. Let me explain again. From the previous code (you gave me) I select the variables and then performed the equations. The last equation is ret(i) = &lt;/SPAN&gt;……… which generates returns for each variable such as ret1 ret2 etc&lt;SPAN style="font-style: inherit;"&gt;. Now I want to subtract each of these returns from average_ret. This average_ret is in another dataset. How can I do that?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;Further, when I subtract ret1 - average_ret, ret2 - average_ret etc. then I cannot identify the main variables. I also need to identify the return difference for each main variable. How can I do that?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;Again, this variable list is for one dataset. I want to do this task for multiple datasets. So do I need to run code for each dataset separately?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;Below is your previous code that you gave me:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;%let varlist = &lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: inherit; color: #000000;"&gt;CA45245E1097 ... &lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: inherit; color: #000000;"&gt;US98974P1003 ; /***I wrote all the variable names***/&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'courier new', courier; color: #000000;"&gt;%let nvar = %sysfunc(countw(&amp;amp;varlist,%str( )));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;data P20040by01;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; set Benchmar.P20040by0 (keep = date &amp;amp;varlist);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier; text-decoration: line-through; color: #ff0000;"&gt;*set Benchmar.P20040by0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; array var (&amp;amp;nvar) &amp;amp;varlist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; array rvar (&amp;amp;nvar) &lt;SPAN style="font-style: inherit; font-family: inherit; text-decoration: line-through; color: #ff0000;"&gt;&amp;amp;varlist&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; array gvar (&amp;amp;nvar) &lt;SPAN style="font-style: inherit; font-family: inherit; text-decoration: line-through; color: #ff0000;"&gt;&amp;amp;varlist&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; array lgvar (&amp;amp;nvar) &lt;SPAN style="color: #ff0000; font-style: inherit; text-decoration: line-through; font-family: inherit;"&gt;&amp;amp;varlist&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; array ret (&amp;amp;nvar) &lt;SPAN style="font-style: inherit; font-family: inherit; text-decoration: line-through; color: #ff0000;"&gt;&amp;amp;varlist&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; do i = 1 to &amp;amp;nvar;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rvar(i) = (var(i&lt;SPAN style="font-style: inherit; font-family: inherit; text-decoration: line-through; color: #ff0000;"&gt;+1&lt;/SPAN&gt;)-lag(var(i&lt;SPAN style="font-style: inherit; font-family: inherit; text-decoration: line-through; color: #ff0000;"&gt;+1&lt;/SPAN&gt;)))/lag(var(i&lt;SPAN style="font-style: inherit; font-family: inherit; text-decoration: line-through; color: #ff0000;"&gt;+1&lt;/SPAN&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gvar(i) = rvar(i)+1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lgvar(i) = lag(gvar(i));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; rgla = mean( of lgvar(*) );&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; do i = 1 to &amp;amp;nvar;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret(i) = (rvar(i)*lgvar(i))/rgla;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 15:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182203#M265240</guid>
      <dc:creator>AbuChowdhury</dc:creator>
      <dc:date>2014-02-21T15:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182204#M265241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;What is 'diff' in your code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 17:20:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182204#M265241</guid>
      <dc:creator>AbuChowdhury</dc:creator>
      <dc:date>2014-02-21T17:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182205#M265242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The name of the variable that you wanted to copy from the other table and subtract from every value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 17:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182205#M265242</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-21T17:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182206#M265243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to generate and post some example input data and the desired output data.&amp;nbsp; For example here is data for 2 dates and 3 firms.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;data one ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; informat date date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; format date date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input date firm1-firm3 ;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;01JAN2013 100 200 300&lt;/P&gt;&lt;P&gt;02JAN2013 101 210 330&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data two;&lt;/P&gt;&lt;P&gt;data one ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; informat date date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; format date date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input date diff ;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;01JAN2013 10&lt;/P&gt;&lt;P&gt;02JAN2013 20&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; informat date date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; format date date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input date diff firm1-firm3 ;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;01JAN2013 10 90 190 290&lt;/P&gt;&lt;P&gt;02JAN2013 20 81 190 310&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 17:37:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182206#M265243</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-21T17:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182207#M265244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will probably get results faster if you normalize your data.&lt;/P&gt;&lt;P&gt;So if you currently have data with 200 columns that represent PRICE for 200 firms you should convert it into 200 rows with one column for the FIRM and another for the PRICE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=have(keep=date firm1-firm200) out=price(rename=(col1=PRICE _name_=FIRM)) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by price;&lt;/P&gt;&lt;P&gt;&amp;nbsp; var firm1-firm200;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort; by firm date; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then if you have another variable that also had collected for each FIRM/DATE combination you could easily merge them and do calculations.&lt;/P&gt;&lt;P&gt;data gain;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; merge price basis ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by firm date ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; gain = price - basis ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 17:43:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182207#M265244</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-21T17:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182208#M265245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am sorry I could not understand this. Is this for my previous question?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 18:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182208#M265245</guid>
      <dc:creator>AbuChowdhury</dc:creator>
      <dc:date>2014-02-21T18:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182209#M265246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just post some examples so we can understand more clearly what you are talking about.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 18:36:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182209#M265246</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-21T18:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182210#M265247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am attaching two files: Benchmark and usa_firms. I need to subtract the last column (average_ret) of Benchmark table from all return columns (ret1, ret2, .... , ret61) of usa_firms.&lt;/P&gt;&lt;P&gt;By the by, can I rename those variables (ret1, ret2, etc) by firm identity (such as US1234456, there are 61 firm identities in usa_firms table. I got these ret1, ret2 …. variable names when I calculated the returns of those firms).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 19:07:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182210#M265247</guid>
      <dc:creator>AbuChowdhury</dc:creator>
      <dc:date>2014-02-21T19:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182211#M265248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So did you try the program I posted?&lt;/P&gt;&lt;P&gt;I notice that you do not seem to have any variable to uniquely identify the rows in the datasets.&amp;nbsp; This should be corrected as you will have a hard time making sure that you are matching the rows without that.&lt;/P&gt;&lt;P&gt;So I took just the first 6 rows and two firm values so I can show you how this can be done. I just took the first two columns, I am not sure if that is what you are calling RET or not, but you should be able to adjust to use the variable names of your columns.&lt;/P&gt;&lt;P&gt;So here are two simple data steps to setup the sample datasets. BENCHMARK will have the AVERAGE_RET variable that you want to merge onto and then subtract. and USA_FIRMS will have the values that you will be subtracting from.&amp;nbsp; I had the data steps define a ROWID variable so that I can make sure to match the rows properly.&amp;nbsp; Also I renamed the DATE variables so I can compare and make sure that the dates from the two different files have not gotten out of line.&amp;nbsp; Also I set the format on the date variables to yymmdd because it leads to less confusion about what is the month and what is the day, also it will sort properly if it is treated as text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data benchmark;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; informat date1 yymmdd10. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; format date1 yymmdd10.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; rowid+1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input date1 average_ret ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards4;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;. .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;. .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2004/01/01 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2004/02/01 0.0336863483&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2004/05/01 0.0416289109&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2004/06/01 -0.001851738&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;;;;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data usa_firms;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; informat date2 yymmdd10. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; format date2 yymmdd10.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; rowid+1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input date2 firm1 firm2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards4;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;. 15.4467 7.82&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;. 15.06 7.76&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2004/01/01 15.06 7.76&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2004/02/01 14.9867 7.91&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2004/05/01 14.6667 8.05&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2004/06/01 &lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; line-height: 1.5em;"&gt;13.2527 8.09&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;;;;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you just need to merge the two datasets so that the variables you want to work with are in the same data vector.&lt;/P&gt;&lt;P&gt;I had it create new variables to old the subtracted values. But you could store the values back into the original variables.&lt;/P&gt;&lt;P&gt;Also I used the DO OVER construct for working with the arrrays.&amp;nbsp; It makes typing the names easier to not have to add the indexes.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; merge benchmark usa_firms ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; by rowid;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if date1 ne date2 then put 'ERROR: DATE MISMATCH. ' date1= date2=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; else do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array firms firm1-firm2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array new&amp;nbsp;&amp;nbsp; new1-new2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do over firms;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new=firms-average_ret; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So lets look at the results and see if it is what you expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put rowid date1 new1 new2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;1 . . .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2 . . .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;3 2004-01-01 15.06 7.76&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;4 2004-02-01 14.953013652 7.8763136517&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;5 2004-05-01 14.625071089 8.0083710891&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;6 2004-06-01 13.254551738 8.091851738&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 19:47:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182211#M265248</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-21T19:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182212#M265249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How did you write the followings in the datastep?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;. .&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;. .&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;2004/01/01 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;2004/02/01 0.0336863483&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;2004/05/01 0.0416289109&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;2004/06/01 -0.001851738&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 20:03:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182212#M265249</guid>
      <dc:creator>AbuChowdhury</dc:creator>
      <dc:date>2014-02-21T20:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182213#M265250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Copy and pasted it from the dataset you posted. I opened the data set with SAS System Viewer, highlighted the first 6 values of the variable and hit control-C for copy, went to the program editor and hit control-V for paste.&amp;nbsp; I then typed in the dates by hand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But you don't need to type the data as you already have it in a dataset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 20:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182213#M265250</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-21T20:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182214#M265251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do I need to install the SAS System Viewer? &lt;/P&gt;&lt;P&gt;You copied only first 6 values, but If I do this for the whole dataset then there will be 264 values. Isn't it too much?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 21:27:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182214#M265251</guid>
      <dc:creator>AbuChowdhury</dc:creator>
      <dc:date>2014-02-21T21:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182215#M265252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not being very clear. The ONLY purpose of the simple data steps I posted was have some common example data that everyone reading the thread could see and play with.&amp;nbsp; You already have data in a datesets, you do NOT need to copy and paste it!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For you to generate the same output I generated starting with the two datasets you posted you could run this program.&amp;nbsp; The dataset options OBS=6 will limit it just using the first 6 rows so that it will look just like what I posted.&amp;nbsp; Of course in realitiy you wouldn't use that option since you want to operate on all of the rows in your datasets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data both ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; merge usa_firms(obs=6 keep=date &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;US4583341098 &lt;/SPAN&gt;US09061G1013)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; benchmark(obs=6 keep=average_ret) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; * NO BY STATEMENT since you do not have any id variable to use to merge ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; array firms US4583341098 US09061G1013 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; array new new1 - new2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do over firms;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new = firms - average_ret ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 22:08:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182215#M265252</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-21T22:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182216#M265253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It works now. But I had to change&amp;nbsp; the date format:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;data benchmark;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; informat date1 yymmdd10. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; format date1 yymmdd10.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;Instead of the above code, I wrote:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;data benchmark;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; informat date1 ddmmyy10. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&amp;nbsp; format date1 ddmmyy10.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;since the date in my dataset was like dd/mm/2004. Am I right?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;Your latest codes also work fine. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;Thank you very much.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 23:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182216#M265253</guid>
      <dc:creator>AbuChowdhury</dc:creator>
      <dc:date>2014-02-21T23:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182217#M265254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes. The INFORMAT is what tells SAS how to convert text values.&amp;nbsp; MMDDYY will read strings in month day year order .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 23:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182217#M265254</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-21T23:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182218#M265255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What's the difference between date10. and date9. and between cards and cards4?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;new1, new2, … etc. calculate the difference between returns from usa_firms table and average_ret from Benchmark table. I want perform the same task for another dataset (say uk_firms). After performing the same operation this newdataset will also show the same variables: new1, new2, … etc. I need to merge these two datasets: usa_firms and uk_firms. It's a problematic since both datasets have same variable names (new1, new2, …&amp;nbsp; ) but those are from two different countries? How can I resolve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you look at the dataset usa_firms, you will see the price data for US firms and US firms are identified as&amp;nbsp; . There are price data for 61 US firms. From these price data, returns are calculated (ret1, ret2, …. (shown in the right end of the dataset)) for those 61 firms. By looking at ret1, ret2 variables I cannot understand which firms' return they are. Is it possible to use firm identity instead of ret1, ret2 variable names? I need to identify the returns for each firm because I need to do the same task for another dataset (uk_firms) and need to merge these two datasets.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Feb 2014 10:43:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182218#M265255</guid>
      <dc:creator>AbuChowdhury</dc:creator>
      <dc:date>2014-02-22T10:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Copy column from one dataset to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182219#M265256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want to continue to use his horizontal format instead of a vertical format then you will need to continually be creating new variable names.&lt;/P&gt;&lt;P&gt;You can use some tricks to help you though.&amp;nbsp; For example below SQL will create two macro variables with space delimited lists of variable names that would be very suited for use in a ARRAY statement.&amp;nbsp;&amp;nbsp; The first list is just the variables of interest and the second is the same but with _RETURN appended to the names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , cats(name,'_return')&lt;/P&gt;&lt;P&gt;into varlist separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , retlist separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp; from dictionary.columns&lt;/P&gt;&lt;P&gt;&amp;nbsp; where libname = 'WORK' and memname = 'USA_FIRMS'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and indexw('&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;US4583341098 US09061G1013',upcase(name))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data .... ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; array firms &amp;amp;varlist;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; array ret &amp;amp;retlist;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ....&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Feb 2014 16:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-column-from-one-dataset-to-another/m-p/182219#M265256</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-22T16:52:32Z</dc:date>
    </item>
  </channel>
</rss>

