<?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 first row value for all rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Copy-first-row-value-for-all-rows/m-p/635748#M188813</link>
    <description>Thanks! I tried retain with first.date to cover myself but this works fine.</description>
    <pubDate>Mon, 30 Mar 2020 09:42:09 GMT</pubDate>
    <dc:creator>PetePatel</dc:creator>
    <dc:date>2020-03-30T09:42:09Z</dc:date>
    <item>
      <title>Copy first row value for all rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-first-row-value-for-all-rows/m-p/635742#M188809</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with variables date, AR and TA2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create AR2 and fix it at the earliest AR date for all subsequent rows (i.e. 2000-01-01). In this case the value should always be&amp;nbsp;0.020158103.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I achieve this in the shortest number of steps? I have tried the retain function as well as a sort, delete and merge but this is quite messy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;AR&lt;/TD&gt;&lt;TD&gt;TA2&lt;/TD&gt;&lt;TD&gt;AR2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2000-01-01&lt;/TD&gt;&lt;TD&gt;0.020158103&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0.020158103&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2000-02-01&lt;/TD&gt;&lt;TD&gt;0.018692771&lt;/TD&gt;&lt;TD&gt;0.021258489&lt;/TD&gt;&lt;TD&gt;0.020158103&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2000-03-01&lt;/TD&gt;&lt;TD&gt;0.021398338&lt;/TD&gt;&lt;TD&gt;0.022432956&lt;/TD&gt;&lt;TD&gt;0.020158103&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2000-04-01&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0.021881263&lt;/TD&gt;&lt;TD&gt;0.020158103&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2000-05-01&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0.022085627&lt;/TD&gt;&lt;TD&gt;0.020158103&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2000-06-01&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0.02190027&lt;/TD&gt;&lt;TD&gt;0.020158103&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2000-07-01&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0.021667115&lt;/TD&gt;&lt;TD&gt;0.020158103&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2000-08-01&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0.021301672&lt;/TD&gt;&lt;TD&gt;0.020158103&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 30 Mar 2020 09:22:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-first-row-value-for-all-rows/m-p/635742#M188809</guid>
      <dc:creator>PetePatel</dc:creator>
      <dc:date>2020-03-30T09:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Copy first row value for all rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-first-row-value-for-all-rows/m-p/635744#M188810</link>
      <description>&lt;P&gt;Does this need to work for by groups as well?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 09:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-first-row-value-for-all-rows/m-p/635744#M188810</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-03-30T09:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Copy first row value for all rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-first-row-value-for-all-rows/m-p/635745#M188811</link>
      <description>Hi thanks for your reply draycut. No, it just needs to work for the earliest date which will always be the first observation as the dataset is sorted in ascending date order.</description>
      <pubDate>Mon, 30 Mar 2020 09:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-first-row-value-for-all-rows/m-p/635745#M188811</guid>
      <dc:creator>PetePatel</dc:creator>
      <dc:date>2020-03-30T09:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Copy first row value for all rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-first-row-value-for-all-rows/m-p/635746#M188812</link>
      <description>&lt;P&gt;Ok. then this will do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Date :anydtdte12. AR TA2;
format date yymmdd10.;
infile datalines dlm=',';
datalines;
2000-01-01,0.020158103,0.020158103
2000-02-01,0.018692771,0.021258489
2000-03-01,0.021398338,0.022432956
2000-04-01,           ,0.021881263
2000-05-01,           ,0.022085627
2000-06-01,           ,0.02190027 
2000-07-01,           ,0.021667115
2000-08-01,           ,0.021301672
;

data want;
   set have;
   if _N_ = 1 then AR2 = AR;
   retain AR2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Mar 2020 09:34:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-first-row-value-for-all-rows/m-p/635746#M188812</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-03-30T09:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: Copy first row value for all rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Copy-first-row-value-for-all-rows/m-p/635748#M188813</link>
      <description>Thanks! I tried retain with first.date to cover myself but this works fine.</description>
      <pubDate>Mon, 30 Mar 2020 09:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Copy-first-row-value-for-all-rows/m-p/635748#M188813</guid>
      <dc:creator>PetePatel</dc:creator>
      <dc:date>2020-03-30T09:42:09Z</dc:date>
    </item>
  </channel>
</rss>

