<?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: Lag function not being recognized by SAS studio in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928073#M365172</link>
    <description>&lt;P&gt;As others already explained: SAS Studio is just the client with some in-built syntax highlighting. This highlighting is not perfect so just take it as guidance.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS Studio sends the code to the SAS server for execution. It's the SAS log created as part of execution that will tell you if some syntax is really valid or not. The syntax you shared is valid so just execute it and inspect the SAS log.&lt;/P&gt;</description>
    <pubDate>Mon, 13 May 2024 05:06:16 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2024-05-13T05:06:16Z</dc:date>
    <item>
      <title>Lag function not being recognized by SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928015#M365149</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running into issues with the lag function. I am able to use lag(variable), if recalling only the observation immediately prior, however I am not able to use lag2(variable), lag3(variable), etc.. As soon as I enter a numerical value (n) next to the lag function, it is no longer highlighted in blue or recognized as a SAS function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Checking my data shows it is not picking up the function, beyond the first lag(variable), with no 'n' specified.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone experienced this? I am using SAS Studio.&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2024 00:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928015#M365149</guid>
      <dc:creator>lewat</dc:creator>
      <dc:date>2024-05-12T00:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function not being recognized by SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928020#M365153</link>
      <description>&lt;P&gt;Not sure what you believe is not working.&lt;/P&gt;
&lt;P&gt;Make sure that in your real code you don't use the lag function conditionally. It only works as you'd expect if it executes for every single row of data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
  set sashelp.class;
  /*Setting lag name of the original name*/
	LAG_name  = lag(name);  *'lag' highlighed in blue;	
	LAG2_name = lag2(name); *'lag' not highlighed;	
	LAG3_name = lag3(name); *'lag' not highlighed;	
	LAG4_name = lag4(name); *'lag' not highlighed;	
run;

proc print data=demo;
  var name lag:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1715487693332.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96451i0CBA7CBA35755277/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1715487693332.png" alt="Patrick_0-1715487693332.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2024 04:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928020#M365153</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-05-12T04:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function not being recognized by SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928023#M365154</link>
      <description>&lt;P&gt;The syntax checker in Studio is not 100% complete, it will miss some elements. The real check happens when you run your code; look at the log.&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2024 10:12:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928023#M365154</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-05-12T10:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function not being recognized by SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928027#M365156</link>
      <description>&lt;P&gt;Perhaps this is it. I am at a loss. I have tried to run my data using the lag functions and this confirms only the first lag(variable) is recognized (before I add a numerical value) as if the numerical value invalidates it. I have attached a screenshot of the code, itself, unhighlighted.&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2024 12:01:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928027#M365156</guid>
      <dc:creator>lewat</dc:creator>
      <dc:date>2024-05-12T12:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function not being recognized by SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928028#M365157</link>
      <description>&lt;P&gt;The lag function is not being used conditionally. Any lag greater than lag of 1 observation is not being recognized as a function, at all. I have attached a screenshot in case this is helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Confirming this issue also persists when I run the code. Lag2 onwards is not recognized.&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2024 12:06:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928028#M365157</guid>
      <dc:creator>lewat</dc:creator>
      <dc:date>2024-05-12T12:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function not being recognized by SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928029#M365158</link>
      <description>&lt;P&gt;Don't let yourself be confused by the coloring of the Studio editor. You know that LAGx is valid, so use it.&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2024 12:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928029#M365158</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-05-12T12:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function not being recognized by SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928054#M365168</link>
      <description>&lt;P&gt;What is the photograph in your PDF file supposed to represent?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1715527388875.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96455i4C1FA30CD8D0D544/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1715527388875.png" alt="Tom_0-1715527388875.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;(and why did you go to the trouble of making a PDF file and uploading it when you can just paste the image into the editor or use the Insert image icon instead of the attach file icon?)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume you are talking about the coloring that the SAS/Studio editor is adding to try and help you?&amp;nbsp; Remember that SAS/studio is NOT the actual SAS processor.&amp;nbsp; It is just a front end tool to help you edit and submit your code to SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to show proof that SAS did not understand the lag2() function then you need to paste in the lines from the SAS log with the error message they generate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2024 15:25:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928054#M365168</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-12T15:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: Lag function not being recognized by SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928073#M365172</link>
      <description>&lt;P&gt;As others already explained: SAS Studio is just the client with some in-built syntax highlighting. This highlighting is not perfect so just take it as guidance.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS Studio sends the code to the SAS server for execution. It's the SAS log created as part of execution that will tell you if some syntax is really valid or not. The syntax you shared is valid so just execute it and inspect the SAS log.&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2024 05:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Lag-function-not-being-recognized-by-SAS-studio/m-p/928073#M365172</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-05-13T05:06:16Z</dc:date>
    </item>
  </channel>
</rss>

