<?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: Missing one observation in the first company ID in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634092#M188182</link>
    <description>&lt;P&gt;I don't want to see "edited" code. I want to see the actual code you are running. And show us the LOG anyway, even if there are no errors or warnings.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Mar 2020 13:12:44 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-03-23T13:12:44Z</dc:date>
    <item>
      <title>Missing one observation in the first company ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634081#M188174</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;My data are sorted by gvkey and year. I ran the following code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if first.gvkey then sales_growth=0;&lt;/P&gt;&lt;P&gt;else sales_growth=log((1+sale)/lag((1+sale)));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;I get sales growth number as expected for the whole data set except the following.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gvkey&amp;nbsp; &amp;nbsp;year&amp;nbsp; &amp;nbsp; &amp;nbsp;sale&amp;nbsp; &amp;nbsp; sales_growth&lt;/P&gt;&lt;P&gt;1004&amp;nbsp; &amp;nbsp; 2000&amp;nbsp; &amp;nbsp; 28796&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;1004&amp;nbsp; &amp;nbsp; 2001&amp;nbsp; &amp;nbsp; 34697&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;1004&amp;nbsp; &amp;nbsp; 2002&amp;nbsp; &amp;nbsp; 36784&amp;nbsp; &amp;nbsp; &amp;nbsp; 0.0601&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is why I am getting missing value in the 2nd year? In my data set 1004 is the first gvkey. The problem is happening only for the first gvkey. For other gvkey I am not having this problem. Can anyone help me please?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 13:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634081#M188174</guid>
      <dc:creator>abdulla</dc:creator>
      <dc:date>2020-03-23T13:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Missing one observation in the first company ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634083#M188176</link>
      <description>&lt;P&gt;Well, you didn't run that exact code. There's no variable "sale" in the data you show, despite what the code you show says. And of course, that code won't run unless its in a DATA step, so let's see the entire DATA step. So, show us the entire LOG (code plus notes, warnings, errors) for this DATA step. Paste the log into the window that appears when you click on the &amp;lt;/&amp;gt; icon so as to preserve the formatting and make it easier for us to read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, show us a portion of the actual data, where the variable names match the variable names in the code.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 12:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634083#M188176</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-23T12:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Missing one observation in the first company ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634091#M188181</link>
      <description>I have edited the code and I don't have any error in the log.</description>
      <pubDate>Mon, 23 Mar 2020 13:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634091#M188181</guid>
      <dc:creator>abdulla</dc:creator>
      <dc:date>2020-03-23T13:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Missing one observation in the first company ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634092#M188182</link>
      <description>&lt;P&gt;I don't want to see "edited" code. I want to see the actual code you are running. And show us the LOG anyway, even if there are no errors or warnings.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 13:12:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634092#M188182</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-23T13:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: Missing one observation in the first company ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634097#M188186</link>
      <description>&lt;P&gt;&lt;BR /&gt;3643 Data comp33;&lt;BR /&gt;3644 set comp3;&lt;BR /&gt;3645 by gvkey fy;&lt;BR /&gt;3646 if first.gvkey then sales_growth=0;&lt;BR /&gt;3647 else sales_growth=log((1+wsale)/lag((1+wsale)));&lt;BR /&gt;3648 run;&lt;BR /&gt;&lt;BR /&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;1 at 3647:19 1 at 3647:32&lt;BR /&gt;NOTE: There were 110195 observations read from the data set WORK.COMP3.&lt;BR /&gt;NOTE: The data set WORK.COMP33 has 110195 observations and 43 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.11 seconds&lt;BR /&gt;cpu time 0.07 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By the way, I don't have any missing observation in my first gvkey and&amp;nbsp; problem is I am missing value for the first gvkey only&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 13:26:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634097#M188186</guid>
      <dc:creator>abdulla</dc:creator>
      <dc:date>2020-03-23T13:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Missing one observation in the first company ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634100#M188189</link>
      <description>&lt;PRE&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
1 at 3647:19 1 at 3647:32&lt;/PRE&gt;
&lt;P&gt;This is telling you there is a problem somewhere. That at line 3647 column 32 a missing value is produced. What happens at column 32 of line 3647 ... you are evaluating the LAG() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The LAG() function doesn't work the way most people think it works. I think you need the LAG() function to be evaluated on every record, not just the records where first.gvkey is zero (because your code only evaluates the LAG() function when first.gvkey is zero).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, this should fix the issue, by evaluating LAG() on every record.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data comp33;
set comp3;
by gvkey fy;
zz=lag(1+wsale);
if first.gvkey then sales_growth=0;
else sales_growth=log((1+wsale)/zz);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 13:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634100#M188189</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-23T13:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Missing one observation in the first company ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634102#M188190</link>
      <description>Paige Miller&lt;BR /&gt;Thank you very much. It works.</description>
      <pubDate>Mon, 23 Mar 2020 13:39:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Missing-one-observation-in-the-first-company-ID/m-p/634102#M188190</guid>
      <dc:creator>abdulla</dc:creator>
      <dc:date>2020-03-23T13:39:24Z</dc:date>
    </item>
  </channel>
</rss>

