<?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: Precision issue when using PROC EXPAND in SAS Forecasting and Econometrics</title>
    <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/674864#M3920</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279507"&gt;@braam&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By default, PROC EXPAND fits a cubic spline function through the nonmissing values of your analysis variable prior to performing any transformations specified in the TRANSFORM= option.&amp;nbsp; This can result in slight precision differences from your original data for some observations, as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;noted.&amp;nbsp; If you do not need to do any missing value interpolation or frequency conversion in PROC EXPAND prior to computing your transformations, then you are correct to specify the METHOD=NONE option.&amp;nbsp; For more details on the METHOD=NONE option, please see the following documentation link:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/?docsetId=etsug&amp;amp;docsetTarget=etsug_expand_details13.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en#etsug_expand000779" target="_self"&gt;https://go.documentation.sas.com/?docsetId=etsug&amp;amp;docsetTarget=etsug_expand_details13.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en#etsug_expand000779&lt;/A&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another alternative is to use the ROUND function to round the results from PROC EXPAND prior to making your comparisons.&amp;nbsp; For example, you could add the statement:&amp;nbsp; &amp;nbsp;lagvar=round(lagvar,1e-8);&amp;nbsp; in your TEMP3 data step prior to your IF statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps!&lt;/P&gt;
&lt;P&gt;DW&lt;/P&gt;</description>
    <pubDate>Wed, 05 Aug 2020 21:03:29 GMT</pubDate>
    <dc:creator>dw_sas</dc:creator>
    <dc:date>2020-08-05T21:03:29Z</dc:date>
    <item>
      <title>Precision issue when using PROC EXPAND</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/674811#M3915</link>
      <description>&lt;P&gt;I just realized that proc expand works in a different way than I expected it would. When I take a lag of the variable, it is actually not the same as the "lag" of the variable. A snippet of my code is as below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc expand data= temp
	out=temp2
/*	method= none*/
	;
	convert Var= LagVar / transformout= (lag 1);
	run;

data temp3;
	set temp2;
	if Var= LagVar then Same= 1; else Same= 0;
	run;

proc print data= temp3;
	format lagVar best20.10;
	var year lagVar Var Same; run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The print statement gives me:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.TEMP3" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;year&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;LagVar&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;var&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Same&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="r data"&gt;2000&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="r data"&gt;2001&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;3&lt;/TH&gt;
&lt;TD class="r data"&gt;2002&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;4&lt;/TH&gt;
&lt;TD class="r data"&gt;2003&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;5&lt;/TH&gt;
&lt;TD class="r data"&gt;2004&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;6&lt;/TH&gt;
&lt;TD class="r data"&gt;2005&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;7&lt;/TH&gt;
&lt;TD class="r data"&gt;2006&lt;/TD&gt;
&lt;TD class="r data"&gt;-2.2204460492503E-16&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;8&lt;/TH&gt;
&lt;TD class="r data"&gt;2007&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;9&lt;/TH&gt;
&lt;TD class="r data"&gt;2008&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;10&lt;/TH&gt;
&lt;TD class="r data"&gt;2009&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;LIke shown in the table, one value looks weird though it is very close to 0 (i.e., the lag value).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Coincidently, I found that adding method=none option seems to solve this, but I'm not entirely sure. Is it a correct solution to this issue? Where does the issue come from? I feel like proc expand is an excellent thing to use, but I am not so confident with its functionality. Many thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2020 18:49:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/674811#M3915</guid>
      <dc:creator>braam</dc:creator>
      <dc:date>2020-08-05T18:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: Precision issue when using PROC EXPAND</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/674820#M3916</link>
      <description>Well yes, numerical precision is always an issue with numbers but I don't see any particular issue with your code/step. &lt;BR /&gt;The comparisons happened correctly and if you use a reasonable format it works fine. Try 20.2 and see what happens. &lt;BR /&gt;&lt;BR /&gt;Depending on what you're doing you can use LAG() within the data step which saves you a step. &lt;BR /&gt;&lt;BR /&gt;But numerical precision is an issue in any computer application including Excel, R and Python.&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Aug 2020 18:55:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/674820#M3916</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-05T18:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: Precision issue when using PROC EXPAND</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/674854#M3917</link>
      <description>Thanks for your reply. I see that the issue happens in year 2007. I expected Same to be 1 for year 2007, but it's 0. Surprisingly, I noticed this (seemingly) randomly in my dataset. Then I feel like method= none is a solution, but not sure.</description>
      <pubDate>Wed, 05 Aug 2020 20:30:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/674854#M3917</guid>
      <dc:creator>braam</dc:creator>
      <dc:date>2020-08-05T20:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Precision issue when using PROC EXPAND</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/674856#M3918</link>
      <description>Yes, I know I can use data step with lag(). But I found proc expand better because I can use "lead" easily.</description>
      <pubDate>Wed, 05 Aug 2020 20:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/674856#M3918</guid>
      <dc:creator>braam</dc:creator>
      <dc:date>2020-08-05T20:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: Precision issue when using PROC EXPAND</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/674862#M3919</link>
      <description>General rule is if you need numeric precision to that degree in your data you would need to use ROUND() in the comparison. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=p0ji1unv6thm0dn1gp4t01a1u0g6.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=p0ji1unv6thm0dn1gp4t01a1u0g6.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;BR /&gt;This page goes in depth into the issues and resolutions.</description>
      <pubDate>Wed, 05 Aug 2020 20:48:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/674862#M3919</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-05T20:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: Precision issue when using PROC EXPAND</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/674864#M3920</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279507"&gt;@braam&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By default, PROC EXPAND fits a cubic spline function through the nonmissing values of your analysis variable prior to performing any transformations specified in the TRANSFORM= option.&amp;nbsp; This can result in slight precision differences from your original data for some observations, as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;noted.&amp;nbsp; If you do not need to do any missing value interpolation or frequency conversion in PROC EXPAND prior to computing your transformations, then you are correct to specify the METHOD=NONE option.&amp;nbsp; For more details on the METHOD=NONE option, please see the following documentation link:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/?docsetId=etsug&amp;amp;docsetTarget=etsug_expand_details13.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en#etsug_expand000779" target="_self"&gt;https://go.documentation.sas.com/?docsetId=etsug&amp;amp;docsetTarget=etsug_expand_details13.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en#etsug_expand000779&lt;/A&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another alternative is to use the ROUND function to round the results from PROC EXPAND prior to making your comparisons.&amp;nbsp; For example, you could add the statement:&amp;nbsp; &amp;nbsp;lagvar=round(lagvar,1e-8);&amp;nbsp; in your TEMP3 data step prior to your IF statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps!&lt;/P&gt;
&lt;P&gt;DW&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2020 21:03:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/674864#M3920</guid>
      <dc:creator>dw_sas</dc:creator>
      <dc:date>2020-08-05T21:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Precision issue when using PROC EXPAND</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/675108#M3923</link>
      <description>Thanks for your answer &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/58092"&gt;@dw_sas&lt;/a&gt;. I'm happy that I could just use METHOD=NONE to solve this issue quickly. &lt;BR /&gt;I would use ROUND if there was no solution for this. But obviously, I need to add a couple of extra lines of coding just for this, which I don't like! Many thanks again.</description>
      <pubDate>Thu, 06 Aug 2020 19:04:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/675108#M3923</guid>
      <dc:creator>braam</dc:creator>
      <dc:date>2020-08-06T19:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Precision issue when using PROC EXPAND</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/675139#M3924</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/58092"&gt;@dw_sas&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for clarifying one of the METHOD=NONE consequences, which I had realize after looking at the documentation when I experienced proc expand results similar to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279507"&gt;@braam&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The linked documentation says&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;When METHOD=NONE is specified, there is no difference between the TRANSFORMIN= and TRANSFORMOUT= options;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To me this language implies, when method is NOT equal to none, there is (could be) a difference between transformin and transformout, &lt;EM&gt;&lt;STRONG&gt;even when the same transformation is specified&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should I interpret this to mean that specifying a transformation in the transformin parameter would circumvent (or precede) the cubic spline interpolation, but moving the same specification to transformout would not circumvent it (thereby creating the possibility of small differences in output value)?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 21:15:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/675139#M3924</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-08-06T21:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Precision issue when using PROC EXPAND</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/675159#M3925</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can see how the sentence you noted in the documentation might be confusing.&amp;nbsp; Let me see if I can clarify it...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For this particular case, where there was:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;no frequency conversion,&lt;/LI&gt;
&lt;LI&gt;no missing value interpolation,&lt;/LI&gt;
&lt;LI&gt;the transformation was a simple lag (or lead) transformation, and&lt;/LI&gt;
&lt;LI&gt;the METHOD=NONE option was &lt;STRONG&gt;not&lt;/STRONG&gt; specified,&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;the final results should be the same regardless of whether you use the TRANSFORMOUT= option or the TRANSFORMIN= option.&amp;nbsp; &amp;nbsp;This is because the cubic spline function is fit through the exact same data values in both cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For other cases, such as when frequency conversion is being done or when missing values are present in the data, you would expect to see differences if you use the TRANSFORMIN= option rather than the TRANSFORMOUT= option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If no frequency conversion or missing value interpolation is required, and all you want to do is perform the requested transformation on the values in the DATA= data set, then it is best to use the METHOD=NONE option in this case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps!&lt;/P&gt;
&lt;P&gt;DW&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 22:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Precision-issue-when-using-PROC-EXPAND/m-p/675159#M3925</guid>
      <dc:creator>dw_sas</dc:creator>
      <dc:date>2020-08-06T22:45:05Z</dc:date>
    </item>
  </channel>
</rss>

