<?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: Forecasts as a Time Series Plot - How to remove predicted values? in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Forecasts-as-a-Time-Series-Plot-How-to-remove-predicted-values/m-p/842385#M16643</link>
    <description>&lt;P&gt;This forum is pretty dead &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Nov 2022 18:55:45 GMT</pubDate>
    <dc:creator>illmatic</dc:creator>
    <dc:date>2022-11-03T18:55:45Z</dc:date>
    <item>
      <title>Forecasts as a Time Series Plot - How to remove predicted values?</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Forecasts-as-a-Time-Series-Plot-How-to-remove-predicted-values/m-p/842019#M16642</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pretty simple question, just wondering what best practices are here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a simple Time-Series forecast built in &lt;STRONG&gt;Build Models&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When imported into &lt;STRONG&gt;Visual Analytics&lt;/STRONG&gt;, the time series always includes predicted values, even when actuals are already posted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd actually like to build a view where the &lt;STRONG&gt;Predicted Values&lt;/STRONG&gt; only show up after the current date where &lt;STRONG&gt;Actual Values&lt;/STRONG&gt; are posted. I'd also enjoy having the line there showing the end of the &lt;STRONG&gt;Actuals&lt;/STRONG&gt; and beginning of the &lt;STRONG&gt;Predicted&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 03:44:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Forecasts-as-a-Time-Series-Plot-How-to-remove-predicted-values/m-p/842019#M16642</guid>
      <dc:creator>illmatic</dc:creator>
      <dc:date>2022-11-02T03:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Forecasts as a Time Series Plot - How to remove predicted values?</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Forecasts-as-a-Time-Series-Plot-How-to-remove-predicted-values/m-p/842385#M16643</link>
      <description>&lt;P&gt;This forum is pretty dead &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 18:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Forecasts-as-a-Time-Series-Plot-How-to-remove-predicted-values/m-p/842385#M16643</guid>
      <dc:creator>illmatic</dc:creator>
      <dc:date>2022-11-03T18:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Forecasts as a Time Series Plot - How to remove predicted values?</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Forecasts-as-a-Time-Series-Plot-How-to-remove-predicted-values/m-p/842488#M16646</link>
      <description>The problem may be that we don't have many Model Studio users here. &lt;BR /&gt;&lt;BR /&gt;It would also help if you post a screen capture of the output you are getting, and if you tell us what version of Visual Analytics you are using.&lt;BR /&gt;&lt;BR /&gt;When you build a forecasting object directly in Visual Analytics, there is normally a line to show where the predicted values begin. But I'm not sure if this is the case for an imported model.&lt;BR /&gt;&lt;BR /&gt;Sam</description>
      <pubDate>Fri, 04 Nov 2022 12:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Forecasts-as-a-Time-Series-Plot-How-to-remove-predicted-values/m-p/842488#M16646</guid>
      <dc:creator>Sam_SAS</dc:creator>
      <dc:date>2022-11-04T12:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Forecasts as a Time Series Plot - How to remove predicted values?</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Forecasts-as-a-Time-Series-Plot-How-to-remove-predicted-values/m-p/842496#M16647</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/434901"&gt;@illmatic&lt;/a&gt;! I do this all the time when producing forecasts. The simplest way is to create a new calculated item for your predicted values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if(notmissing('actual'n) ) return .
    else 'predict'n&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will set Predict to missing wherever there are actuals, but you'll have a line break. If you do not want to have a line break, you just need to do a little bit of data prep. Let's use an example of a forecast from PROC ESM:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc esm data=sashelp.air outfor=outfor;
    id date interval=month;
    forecast air / model=multseasonal;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's scroll down to where actuals end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&lt;STRONG&gt;DATE&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&lt;STRONG&gt;ACTUAL&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&lt;STRONG&gt;PREDICT&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;OCT1960&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;461&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;433&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;NOV1960&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;390&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;390&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;DEC1960&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;432&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;429&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;JAN1961&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;.&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;445&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;FEB1961&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;.&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;419&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;MAR1961&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;.&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;469&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To make the lines connect, we need to set predict to missing&amp;nbsp;before the last date of actuals. In other words, we want this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&lt;STRONG&gt;DATE&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&lt;STRONG&gt;ACTUAL&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&lt;STRONG&gt;PREDICT&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;OCT1960&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;461&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;NOV1960&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;390&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&lt;STRONG&gt;DEC1960&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&lt;STRONG&gt;432&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&lt;STRONG&gt;429&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;JAN1961&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;445&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;FEB1961&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;419&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;MAR1961&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;469&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With a little SQL and DATA Step logic, we can do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Read the last actual date into a macro variable */
proc sql noprint;
    select max(date)
    into :last_actual_date
    from outfor
    where actual NE .
    ;
quit;

/* Set predict to missing before the last actual date */
data outfor2;
    set outfor;
    
    if(date &amp;lt; &amp;amp;last_actual_date.) then predict = .;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you load your data into Visual Analytics, you'll have no fitted values in the past and a connecting line once predictions begin.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 13:33:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Forecasts-as-a-Time-Series-Plot-How-to-remove-predicted-values/m-p/842496#M16647</guid>
      <dc:creator>Stu_SAS</dc:creator>
      <dc:date>2022-11-04T13:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: Forecasts as a Time Series Plot - How to remove predicted values?</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Forecasts-as-a-Time-Series-Plot-How-to-remove-predicted-values/m-p/842538#M16648</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/61362"&gt;@Stu_SAS&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My current issue is that I still get predicted values after realized dates with that logic. I believe it is because of the hierarchies. I'll try to breakout the dataset more and tweak the logic from there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you have some experience with visualizing models, do you have a current best method in regard to automating a refresh?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm noticing that I have to reload the dataset, re-run the pipelines, export the dataset, and only then do my visuals have refreshed data. Wondering if it's possible to script it all, current code output scheduling from the pipeline section doesn't seem complete, but I may be wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 16:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Forecasts-as-a-Time-Series-Plot-How-to-remove-predicted-values/m-p/842538#M16648</guid>
      <dc:creator>illmatic</dc:creator>
      <dc:date>2022-11-04T16:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Forecasts as a Time Series Plot - How to remove predicted values?</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Forecasts-as-a-Time-Series-Plot-How-to-remove-predicted-values/m-p/842551#M16650</link>
      <description>&lt;P&gt;In Viya I would register the model to Model Manager, then save the scoring code as a .sas file in a folder within SAS Studio. From there, you can schedule it to run as a job in Environment Manager. Your code can then run on a regular batch schedule.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS 9.4 we would use a dedicated scheduler, like Cron in Linux, to run SAS jobs. Since Viya has a built-in batch code runner, we don't need to use it anymore. A great paper on best practices for scheduling in Viya can be found below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2020/4248-2020.pdf" target="_blank" rel="noopener"&gt;https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2020/4248-2020.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to run a pipeline in batch can be found here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/vfcdc/v_015/vfug/n194n9wnp2xokzn15f9gwn3ejtjo.htm" target="_blank" rel="noopener"&gt;https://go.documentation.sas.com/doc/en/vfcdc/v_015/vfug/n194n9wnp2xokzn15f9gwn3ejtjo.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your general code flow would look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;lt;copied batch score code goes here&amp;gt;

caslib _ALL_ assign;

proc casutil incaslib='myvacaslib';
    droptable casdata='mytable';
quit;

data myvacaslib.mytable(promote=yes);
    set modeloutputcaslib.mymodeldata;
run;

proc casutil incaslib='myvacaslib';
    save casdata='mytable' replace;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Nov 2022 19:06:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Forecasts-as-a-Time-Series-Plot-How-to-remove-predicted-values/m-p/842551#M16650</guid>
      <dc:creator>Stu_SAS</dc:creator>
      <dc:date>2022-11-04T19:06:39Z</dc:date>
    </item>
  </channel>
</rss>

