<?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: Create a column of repeated values based on the earliest value of another column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-column-of-repeated-values-based-on-the-earliest-value/m-p/577692#M163717</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
  
data have;
input var1 date : anydtdte7.;
format date monyy7.;
cards;
1.1  Feb2018
1.4  Mar2018
2.6  Apr2018
3.3  May2018
4.5  Jun2018
;


proc sql;
create table want as
select *,(select var1  from have  having date=min(date)) as base
from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 30 Jul 2019 12:17:06 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-07-30T12:17:06Z</dc:date>
    <item>
      <title>Create a column of repeated values based on the earliest value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-column-of-repeated-values-based-on-the-earliest-value/m-p/577652#M163706</link>
      <description>&lt;P&gt;I'm sure there's a simple solution to this problem, but I'm a new enough user so here goes. I'm using SAS enterprise guide. I have a dataset like so&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;var1 date&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;1.1&amp;nbsp; Feb2018&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;1.4&amp;nbsp; Mar2018&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;2.6&amp;nbsp; Apr2018&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;3.3&amp;nbsp; May2018&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;4.5&amp;nbsp; Jun2018&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;and I would like to create a column that repeats the earliest var1 value, like so&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;var1 date&amp;nbsp; &amp;nbsp; base&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;1.1&amp;nbsp; Feb2018 1.1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;1.4&amp;nbsp; Mar2018 1.1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;2.6&amp;nbsp; Apr2018 1.1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;3.3&amp;nbsp; May2018 1.1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;4.5&amp;nbsp; Jun2018 1.1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure if I should use proc sql or a data step here. Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 10:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-column-of-repeated-values-based-on-the-earliest-value/m-p/577652#M163706</guid>
      <dc:creator>davkav9</dc:creator>
      <dc:date>2019-07-30T10:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create a column of repeated values based on the earliest value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-column-of-repeated-values-based-on-the-earliest-value/m-p/577681#M163711</link>
      <description>&lt;P&gt;Assuming the data is sorted by var, you should be able to use a retain statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
	set vardate;
	retain base;&lt;BR /&gt;	if _N_ = 1 then base = var;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can expand this to grouped data (for example if you had another column ahead) using "BY" and "first." statement.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 11:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-column-of-repeated-values-based-on-the-earliest-value/m-p/577681#M163711</guid>
      <dc:creator>PrestickNinja</dc:creator>
      <dc:date>2019-07-30T11:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create a column of repeated values based on the earliest value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-column-of-repeated-values-based-on-the-earliest-value/m-p/577684#M163712</link>
      <description>Perfect, exactly what I wanted. Thank you!</description>
      <pubDate>Tue, 30 Jul 2019 11:43:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-column-of-repeated-values-based-on-the-earliest-value/m-p/577684#M163712</guid>
      <dc:creator>davkav9</dc:creator>
      <dc:date>2019-07-30T11:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create a column of repeated values based on the earliest value of another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-column-of-repeated-values-based-on-the-earliest-value/m-p/577692#M163717</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
  
data have;
input var1 date : anydtdte7.;
format date monyy7.;
cards;
1.1  Feb2018
1.4  Mar2018
2.6  Apr2018
3.3  May2018
4.5  Jun2018
;


proc sql;
create table want as
select *,(select var1  from have  having date=min(date)) as base
from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jul 2019 12:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-column-of-repeated-values-based-on-the-earliest-value/m-p/577692#M163717</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-30T12:17:06Z</dc:date>
    </item>
  </channel>
</rss>

