<?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: Stop computing last few values generated by Proc expand in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/742988#M232525</link>
    <description>&lt;P&gt;Define "last raw observation".&lt;/P&gt;
&lt;P&gt;There is no way for use to tell what that is.&lt;/P&gt;</description>
    <pubDate>Fri, 21 May 2021 17:47:23 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-05-21T17:47:23Z</dc:date>
    <item>
      <title>Stop computing last few values generated by Proc expand</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/742878#M232465</link>
      <description>&lt;P&gt;I'm using proc expand to calculate the 7 day midpoint average for a number of variables by date, and would like for it to stop calculating past the last raw value entered for each variable, where the last date of entry for variables are all different. This is my code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc expand data=before out=after;&lt;/P&gt;&lt;P&gt;convert variable1 = variable1 _avg variable2=variable2_avg/ method=none transformout=(CMOVAVE 7);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the output:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Variable1&lt;/TD&gt;&lt;TD&gt;Variable1_avg&lt;/TD&gt;&lt;TD&gt;Variable2&lt;/TD&gt;&lt;TD&gt;Variable2_avg&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;TD&gt;…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&gt;22-Jan-21&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23-Jan-21&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;24-Jan-21&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;And I would like it to stop computing past the date of the last raw values, i.e. exclude the bolded values. Would I able to do this by modifying the proc expand statement? Or an array/another method for the large number of variables?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: for clarification, there were no data entered for variable1 after January 17 and for variable2&amp;nbsp; after January 19.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 19:01:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/742878#M232465</guid>
      <dc:creator>DSAS_er</dc:creator>
      <dc:date>2021-05-21T19:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Stop computing last few values generated by Proc expand</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/742888#M232469</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is an amazing procedure. Unfortunately I do not have SAS/ETS to test and use it.&lt;/P&gt;
&lt;P&gt;I do not know if the procedure is able to proceed your request, but merging back the original values to your output dataset may be a suitable workaround&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 13:16:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/742888#M232469</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2021-05-21T13:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: Stop computing last few values generated by Proc expand</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/742909#M232486</link>
      <description>&lt;P&gt;The basic approach would likely be to filter the resulting data and not try to get Proc Expand not to do what it is designed to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is not obvious what values of what variable(s) would be used to determine the filter though.&lt;/P&gt;
&lt;P&gt;And I am not sure if you want to have the bolded values set to missing or all the data from 18JAN and later removed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, I recommend using dates with 4 years for clarity.&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 14:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/742909#M232486</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-21T14:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Stop computing last few values generated by Proc expand</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/742922#M232490</link>
      <description>&lt;P&gt;Thanks for responding. The dataset is merely an example, so assuming that all date are in 2021, by day, and sorted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I would like the bolded values set to missing as of the subsequent row for the last raw observation.&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 15:22:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/742922#M232490</guid>
      <dc:creator>DSAS_er</dc:creator>
      <dc:date>2021-05-21T15:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Stop computing last few values generated by Proc expand</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/742988#M232525</link>
      <description>&lt;P&gt;Define "last raw observation".&lt;/P&gt;
&lt;P&gt;There is no way for use to tell what that is.&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 17:47:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/742988#M232525</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-21T17:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Stop computing last few values generated by Proc expand</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/743017#M232536</link>
      <description>&lt;P&gt;Oh, as in there are no subsequent values following that date, so the last date of data for variable1 is January 17 and for variable2 January 19, nothing more since.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 18:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/743017#M232536</guid>
      <dc:creator>DSAS_er</dc:creator>
      <dc:date>2021-05-21T18:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Stop computing last few values generated by Proc expand</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/743070#M232558</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/335810"&gt;@DSAS_er&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Oh, as in there are no subsequent values following that date, so the last date of data for variable1 is January 17 and for variable2 January 19, nothing more since.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Finally something that almost resembles are rule.&lt;/P&gt;
&lt;P&gt;So you use the OUTPUT from Proc expand:&lt;/P&gt;
&lt;PRE&gt;Data want;
   set after;
   if date &amp;gt; '17JAN2021'd then call missing(Variable1_avg);
   if date &amp;gt; '19JAN2021'd then call missing(Variable2_avg);
run;&lt;/PRE&gt;
&lt;P&gt;If you expect to do something like this "automagically" you would need to process the input data set for proc expand, find the last valid row and find a way to provide those dates to the data step. This could involve macro language, summarizing the data to get data and merge it with the "after" data or possibly hash objects. There are several ways depending on complexity of data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the data is ugly enough and not too long it may be easiest to just look at the results in the AFTER and write a data step like I did.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 May 2021 22:30:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stop-computing-last-few-values-generated-by-Proc-expand/m-p/743070#M232558</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-21T22:30:43Z</dc:date>
    </item>
  </channel>
</rss>

