<?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 SUM a variable with BY command over a five-year horizon in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/SUM-a-variable-with-BY-command-over-a-five-year-horizon/m-p/587553#M14705</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS (using SAS 9.4) and I need some help with one variable I use for my research.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to generate a variable (let's call it variable A for simplicity), which is the sum of variable B over a five-year horizon, from the current year back to four years ago&lt;SPAN style="background-color: transparent; color: #333333; cursor: text; display: inline; float: none; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 16.8px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;&amp;nbsp;(i.e. from year t-4 to year t)&lt;/SPAN&gt;. I also needs to use BY Group command for variable A to make sure the sum is with respect to each firm.&amp;nbsp;On top of this, variable B needs to have at least three consecutive years of non-missing data for computing variable A.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looked at the SUM function and I couldn't figure out how to do the sum for an interval with BY command, and also considering non-missing value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really appreciate any help. Thanks a lot in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jiaxin&lt;/P&gt;</description>
    <pubDate>Tue, 10 Sep 2019 15:21:20 GMT</pubDate>
    <dc:creator>jiaxinyang</dc:creator>
    <dc:date>2019-09-10T15:21:20Z</dc:date>
    <item>
      <title>SUM a variable with BY command over a five-year horizon</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SUM-a-variable-with-BY-command-over-a-five-year-horizon/m-p/587553#M14705</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS (using SAS 9.4) and I need some help with one variable I use for my research.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to generate a variable (let's call it variable A for simplicity), which is the sum of variable B over a five-year horizon, from the current year back to four years ago&lt;SPAN style="background-color: transparent; color: #333333; cursor: text; display: inline; float: none; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 16.8px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;&amp;nbsp;(i.e. from year t-4 to year t)&lt;/SPAN&gt;. I also needs to use BY Group command for variable A to make sure the sum is with respect to each firm.&amp;nbsp;On top of this, variable B needs to have at least three consecutive years of non-missing data for computing variable A.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looked at the SUM function and I couldn't figure out how to do the sum for an interval with BY command, and also considering non-missing value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really appreciate any help. Thanks a lot in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jiaxin&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2019 15:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SUM-a-variable-with-BY-command-over-a-five-year-horizon/m-p/587553#M14705</guid>
      <dc:creator>jiaxinyang</dc:creator>
      <dc:date>2019-09-10T15:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: SUM a variable with BY command over a five-year horizon</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SUM-a-variable-with-BY-command-over-a-five-year-horizon/m-p/587571#M14707</link>
      <description>&lt;P&gt;You'll have to do the testing to see if there are 3 years without missings separately, but PROC SUMMARY will do sums of BY groups over the desired time period.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2019 15:37:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SUM-a-variable-with-BY-command-over-a-five-year-horizon/m-p/587571#M14707</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-10T15:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: SUM a variable with BY command over a five-year horizon</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SUM-a-variable-with-BY-command-over-a-five-year-horizon/m-p/587575#M14708</link>
      <description>&lt;P&gt;Hi Paige,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your prompt reply. I will look at&amp;nbsp;&lt;SPAN&gt;PROC SUMMARY first.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there a command I can use to check the missing values for each firm? I need BY groups&amp;nbsp;to see if there are 3 years without missing values as well.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks again for your help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Jiaxin&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2019 15:43:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SUM-a-variable-with-BY-command-over-a-five-year-horizon/m-p/587575#M14708</guid>
      <dc:creator>jiaxinyang</dc:creator>
      <dc:date>2019-09-10T15:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: SUM a variable with BY command over a five-year horizon</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SUM-a-variable-with-BY-command-over-a-five-year-horizon/m-p/587582#M14709</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289385"&gt;@jiaxinyang&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;Is there a command I can use to check the missing values for each firm? I need BY groups&amp;nbsp;to see if there are 3 years without missing values as well.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You have to program this yourself. PROC SUMMARY can count the number of missings over a three year period for each BY group, using the NMISS= output option. Then you know which BY groups don't meet the criterion and you can exclude them from the SUM, which would happen in the next PROC SUMMARY.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2019 15:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SUM-a-variable-with-BY-command-over-a-five-year-horizon/m-p/587582#M14709</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-10T15:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: SUM a variable with BY command over a five-year horizon</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SUM-a-variable-with-BY-command-over-a-five-year-horizon/m-p/587583#M14710</link>
      <description>&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2019 15:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SUM-a-variable-with-BY-command-over-a-five-year-horizon/m-p/587583#M14710</guid>
      <dc:creator>jiaxinyang</dc:creator>
      <dc:date>2019-09-10T15:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: SUM a variable with BY command over a five-year horizon</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SUM-a-variable-with-BY-command-over-a-five-year-horizon/m-p/593394#M15513</link>
      <description>&lt;P&gt;Hi Paige Miller,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wasn't able to use NMISS as I cannot find any similar examples.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are what I have in my dataset. The year identifier -- fyear, the company identifier -- gvkey and the variable interested -- txt. I want the sum of txt over a five year period (year t to year t-4) and require at least three consecutive years of non-missing data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please let me know what codes I need to use or give me some examples I can refer to?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jiaxin&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 14:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SUM-a-variable-with-BY-command-over-a-five-year-horizon/m-p/593394#M15513</guid>
      <dc:creator>jiaxinyang</dc:creator>
      <dc:date>2019-10-02T14:40:39Z</dc:date>
    </item>
  </channel>
</rss>

