<?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: how to add data automatically to the missing days in historical prices according to the prev. pr in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-data-automatically-to-the-missing-days-in-historical/m-p/789418#M252611</link>
    <description>&lt;P&gt;Please provide data in usable form. Excel files are not usable as SAS datasets, but data steps with datalines are.&lt;/P&gt;
&lt;P&gt;See an example for a "look-ahead":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input day :yymmdd10. price;
format day yymmdd10.;
datalines;
2021-12-01 3
2021-12-02 3
2021-12-03 4
2021-12-10 5
;

data want;
merge
  have
  have (
    firstobs=2
    keep=day
    rename=(day=_day)
  )
  end=done
;
output;
if not done then
do day = day + 1 to _day - 1;
  output;
end;
drop _day;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 11 Jan 2022 09:28:03 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-01-11T09:28:03Z</dc:date>
    <item>
      <title>how to add data automatically to the missing days in historical prices according to the prev. price</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-data-automatically-to-the-missing-days-in-historical/m-p/789416#M252609</link>
      <description>&lt;P&gt;I wonder how to add data automatically to the missing days in historical prices according to previous available days price.&lt;/P&gt;
&lt;P&gt;My sample data is attached, as you see i have data for the first three days of december and my next available data is on the 10th of december.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;What i want is to expand my table from 4th of december to the 9th of december with the previous price which is 6900 and so on&lt;/STRONG&gt;&lt;/U&gt;.&lt;/P&gt;
&lt;P&gt;I also attached a second file which is the expanded table i need as a result.&lt;/P&gt;
&lt;P&gt;Any help would be so much appreciated.Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 09:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-data-automatically-to-the-missing-days-in-historical/m-p/789416#M252609</guid>
      <dc:creator>chinaski</dc:creator>
      <dc:date>2022-01-11T09:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to add data automatically to the missing days in historical prices according to the prev. pr</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-data-automatically-to-the-missing-days-in-historical/m-p/789418#M252611</link>
      <description>&lt;P&gt;Please provide data in usable form. Excel files are not usable as SAS datasets, but data steps with datalines are.&lt;/P&gt;
&lt;P&gt;See an example for a "look-ahead":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input day :yymmdd10. price;
format day yymmdd10.;
datalines;
2021-12-01 3
2021-12-02 3
2021-12-03 4
2021-12-10 5
;

data want;
merge
  have
  have (
    firstobs=2
    keep=day
    rename=(day=_day)
  )
  end=done
;
output;
if not done then
do day = day + 1 to _day - 1;
  output;
end;
drop _day;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jan 2022 09:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-data-automatically-to-the-missing-days-in-historical/m-p/789418#M252611</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-11T09:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to add data automatically to the missing days in historical prices according to the prev. pr</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-data-automatically-to-the-missing-days-in-historical/m-p/789457#M252626</link>
      <description>&lt;P&gt;I managed to figure out the solution, for those who would need the code i put here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;If the previous price exists and if there is no price in at least one of the following days, we take it from the previous one.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc timeseries data=work.sample_data out=sample_serie;&lt;BR /&gt;by WEB_SITE PRODUCT_NAME;&lt;BR /&gt;id DATE interval=day&lt;BR /&gt;accumulate=mean&lt;BR /&gt;setmiss=previous&lt;BR /&gt;start='01dec2021'd&lt;BR /&gt;end ='31dec2021'd;&lt;BR /&gt;var product_price;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;If there is no price on the first day of the month, we get it from the next available data.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc timeseries data=work.sample_seri out=sample_serie2;&lt;BR /&gt;by WEB_SITE PRODUCT_NAME;&lt;BR /&gt;id DATE interval=day&lt;BR /&gt;accumulate=mean&lt;BR /&gt;setmiss=next&lt;BR /&gt;start='01dec2021'd&lt;BR /&gt;end ='31dec2021'd;&lt;BR /&gt;var product_price;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 13:40:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-data-automatically-to-the-missing-days-in-historical/m-p/789457#M252626</guid>
      <dc:creator>chinaski</dc:creator>
      <dc:date>2022-01-11T13:40:10Z</dc:date>
    </item>
  </channel>
</rss>

