<?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: Is it allowed to use BY right after a variable being calculated in the same datastep? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-it-allowed-to-use-BY-right-after-a-variable-being-calculated/m-p/722967#M224269</link>
    <description>&lt;P&gt;Thank you very much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not only about the problem solving, but also about leading me to Maxim (previously I read a couple of discussion in this forum and catches this word sometimes but do not know what they are and think maybe it is the specific word for this topic", Now after your reply, I searched for a link and, wow, it is so cool to learn.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2019/3062-2019.pdf" target="_blank" rel="noopener"&gt;https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2019/3062-2019.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp; and other experts for delivering us such an amazing document.&lt;/P&gt;
&lt;P&gt;Best regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Mar 2021 20:10:12 GMT</pubDate>
    <dc:creator>Phil_NZ</dc:creator>
    <dc:date>2021-03-02T20:10:12Z</dc:date>
    <item>
      <title>Is it allowed to use BY right after a variable being calculated in the same datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-allowed-to-use-BY-right-after-a-variable-being-calculated/m-p/722821#M224191</link>
      <description>&lt;P&gt;Hi SAS Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the code below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data var_cal;
	set my.keepvar_1999_2001_1;
	gviidkey=catx('_',gvkey,iid);
	prccd_abs= abs(prccd);&lt;BR /&gt;
	by gviidkey;
	lagprccd_abs=ifn(first.gviidkey,.,lag(prccd_abs));
	lagajexdi=ifn(first.gviidkey,.,lag(ajexdi));
	lagtrfd=ifn(first.gviidkey,.,lag(trfd));
	
	If n(prccd_abs,ajexdi,trfd,lagprccd_abs,lagajexdi,lagtrfd)=6 then
	raw_return=((prccd_abs/ajexdi*trfd)/(lagprccd_abs/ladajexdi*lagtrfd)-1)*100;
	log_raw_return=log(raw_return);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am not sure whether it is accepted that I can use &lt;STRONG&gt;BY gviidkey&lt;/STRONG&gt; when this variable was calculated right above as noted in the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 09:18:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-allowed-to-use-BY-right-after-a-variable-being-calculated/m-p/722821#M224191</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-02T09:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Is it allowed to use BY right after a variable being calculated in the same datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-allowed-to-use-BY-right-after-a-variable-being-calculated/m-p/722828#M224197</link>
      <description>&lt;P&gt;What happens if you execute the code?&lt;/P&gt;
&lt;P&gt;See Maxim 4 &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 09:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-allowed-to-use-BY-right-after-a-variable-being-calculated/m-p/722828#M224197</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-03-02T09:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Is it allowed to use BY right after a variable being calculated in the same datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-allowed-to-use-BY-right-after-a-variable-being-calculated/m-p/722838#M224202</link>
      <description>&lt;P&gt;Maxim 1: Read the Documentation.&lt;/P&gt;
&lt;P&gt;From&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p0yeyftk8ftuckn1o5qzy53284gz.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;BY Statement&lt;/A&gt;&amp;nbsp;in Data Step Programming / Data Step Statements:&lt;/P&gt;
&lt;H3 id="p1qjh2ytb0b37en1ptvfgmoxwkrx" class="xisDoc-title"&gt;Required Argument&lt;/H3&gt;
&lt;DIV id="n0dmmex0fsbmj0n1gcl0fexcslcy" class="xisDoc-argDescriptionPair"&gt;
&lt;H4 class="xisDoc-argument"&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;variable&lt;/EM&gt;&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;names each variable by which the data set is sorted or indexed.&lt;/P&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;This implies that the variable is present in the input dataset(s).&lt;/P&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;Next, Maxim 4: Try It.&lt;/P&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;See this simple log piece:&lt;/P&gt;
&lt;PRE&gt; 73         data want;
 74         set sashelp.class;
 75         check = name !! sex;
 76         by check;
 77         run;
 
 ERROR: BY variable check is not on input data set SASHELP.CLASS.
&lt;/PRE&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;Your code would only run without an ERROR if gviidkey was already present in the input dataset, and it would positively not do what you expect.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 Mar 2021 11:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-allowed-to-use-BY-right-after-a-variable-being-calculated/m-p/722838#M224202</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-02T11:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Is it allowed to use BY right after a variable being calculated in the same datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-allowed-to-use-BY-right-after-a-variable-being-calculated/m-p/722967#M224269</link>
      <description>&lt;P&gt;Thank you very much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not only about the problem solving, but also about leading me to Maxim (previously I read a couple of discussion in this forum and catches this word sometimes but do not know what they are and think maybe it is the specific word for this topic", Now after your reply, I searched for a link and, wow, it is so cool to learn.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2019/3062-2019.pdf" target="_blank" rel="noopener"&gt;https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2019/3062-2019.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp; and other experts for delivering us such an amazing document.&lt;/P&gt;
&lt;P&gt;Best regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 20:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-allowed-to-use-BY-right-after-a-variable-being-calculated/m-p/722967#M224269</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-02T20:10:12Z</dc:date>
    </item>
  </channel>
</rss>

