<?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: Calculated equivalent for data step in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Calculated-equivalent-for-data-step/m-p/554713#M9556</link>
    <description>&lt;P&gt;To focus on one part of your question, the WHERE statement does not use calculated fields.&amp;nbsp; With exceedingly rare exceptions, it only references fields that already exist in the SAS data set.&amp;nbsp; I'm not sure if this will confuse matters or suggest greater insight, but here's a test program you can run:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
do k=1 to 20;
   output;
end;
run;

data test2;
set test1;
k=50;
where k &amp;lt; 5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You will get the 4 observations that have K &amp;lt; 5, before any calculations have been applied.&amp;nbsp; But the final value of K will be 50, after the calculations have been applied.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Apr 2019 14:28:43 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-04-29T14:28:43Z</dc:date>
    <item>
      <title>Calculated equivalent for data step</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculated-equivalent-for-data-step/m-p/554697#M9549</link>
      <description>&lt;P&gt;Apologies - this is a rather basic question although I've spent some time searching and can't seem to find a succinct explanation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm interested in knowing why there is no equivalent to 'calculated' (from Proc SQL) within Data Step syntax? Believe this is down to how the code is compiled and processed, Proc SQL being simultaneous and SAS data step being sequential? Does this then mean that when using a 'Where' clause within a datastep, it's not possible to do so using a calculated field? Is there any way around this to increase efficiency or is it only possible to use Proc SQL for this purpose?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks. D.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 13:47:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculated-equivalent-for-data-step/m-p/554697#M9549</guid>
      <dc:creator>dm2018</dc:creator>
      <dc:date>2019-04-29T13:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated equivalent for data step</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculated-equivalent-for-data-step/m-p/554699#M9551</link>
      <description>&lt;P&gt;The main difference is that in a data step you cannot reference two variables with the same name from different sources like you could in an SQL statement, so there is no need to clarify which variable you mean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also a data step processes code in sequential order.&amp;nbsp; So if you want to reference a variable after its value has been "calculated" then just place the reference later in the program flow and it will get the value after it has changed.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 13:59:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculated-equivalent-for-data-step/m-p/554699#M9551</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-29T13:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated equivalent for data step</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculated-equivalent-for-data-step/m-p/554713#M9556</link>
      <description>&lt;P&gt;To focus on one part of your question, the WHERE statement does not use calculated fields.&amp;nbsp; With exceedingly rare exceptions, it only references fields that already exist in the SAS data set.&amp;nbsp; I'm not sure if this will confuse matters or suggest greater insight, but here's a test program you can run:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
do k=1 to 20;
   output;
end;
run;

data test2;
set test1;
k=50;
where k &amp;lt; 5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You will get the 4 observations that have K &amp;lt; 5, before any calculations have been applied.&amp;nbsp; But the final value of K will be 50, after the calculations have been applied.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 14:28:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculated-equivalent-for-data-step/m-p/554713#M9556</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-29T14:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated equivalent for data step</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculated-equivalent-for-data-step/m-p/554813#M9569</link>
      <description>&lt;P&gt;In a data step, "where" (either as a statement or a dataset option) works exclusively on incoming data. If you want to select on newly created variables, you have to use a&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.3&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p1cxl8ifdt8u0gn12wqbji8o5fq1.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;subsetting if&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 18:44:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculated-equivalent-for-data-step/m-p/554813#M9569</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-29T18:44:20Z</dc:date>
    </item>
  </channel>
</rss>

