<?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 Error when using last.type in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-when-using-last-type/m-p/669116#M200684</link>
    <description>&lt;P&gt;Hi SAS community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your dedicated helps recently, I learn a lot from it, I will try my best to upgrade my skills better to help the others in the future.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, I have the data as below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.PNG" style="width: 571px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47117iA2310C686F28568A/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.PNG" alt="1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.PNG" style="width: 574px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47118i9878498589375D09/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.PNG" alt="2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.PNG" style="width: 577px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47120i71D19F95E4117C16/image-dimensions/577x70?v=v2" width="577" height="70" role="button" title="3.PNG" alt="3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="4.PNG" style="width: 577px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47119i01F2ED054F751851/image-size/large?v=v2&amp;amp;px=999" role="button" title="4.PNG" alt="4.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;while Type is the column of different stocks (character variables), others are numeric variables (daily data from1/1/1987 to 31/12/2019).&lt;/P&gt;
&lt;P&gt;From this dataset have, I want to get the data of &lt;STRONG&gt;p_us, up_us, nosh&lt;/STRONG&gt; at the end of each year for each stock (distinct Type).&lt;/P&gt;
&lt;P&gt;My code is as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
set have;
by Type year;
if last.year then 
    do;
p_us_=p_us;
vo_=vo;
nosh_=nosh;
    end;
else delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And when summarising the results that I receive, I saw that the data for &lt;STRONG&gt;vo, trading_vol, amihud, vo_&lt;/STRONG&gt; ends up with &lt;EM&gt;&lt;STRONG&gt;0 observation&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;as the proc means indicates below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=have;
title"have";
run;
proc means data=want;
title"want";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="result.PNG" style="width: 418px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47121iA020109F16F29264/image-size/large?v=v2&amp;amp;px=999" role="button" title="result.PNG" alt="result.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also check my logic in my code but cannot find out the reason why it ends up like that, can you please have a look and point me out what should be the possibilities of such a result?&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Tue, 14 Jul 2020 08:05:20 GMT</pubDate>
    <dc:creator>Phil_NZ</dc:creator>
    <dc:date>2020-07-14T08:05:20Z</dc:date>
    <item>
      <title>Error when using last.type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-when-using-last-type/m-p/669116#M200684</link>
      <description>&lt;P&gt;Hi SAS community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your dedicated helps recently, I learn a lot from it, I will try my best to upgrade my skills better to help the others in the future.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, I have the data as below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.PNG" style="width: 571px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47117iA2310C686F28568A/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.PNG" alt="1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.PNG" style="width: 574px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47118i9878498589375D09/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.PNG" alt="2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.PNG" style="width: 577px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47120i71D19F95E4117C16/image-dimensions/577x70?v=v2" width="577" height="70" role="button" title="3.PNG" alt="3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="4.PNG" style="width: 577px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47119i01F2ED054F751851/image-size/large?v=v2&amp;amp;px=999" role="button" title="4.PNG" alt="4.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;while Type is the column of different stocks (character variables), others are numeric variables (daily data from1/1/1987 to 31/12/2019).&lt;/P&gt;
&lt;P&gt;From this dataset have, I want to get the data of &lt;STRONG&gt;p_us, up_us, nosh&lt;/STRONG&gt; at the end of each year for each stock (distinct Type).&lt;/P&gt;
&lt;P&gt;My code is as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
set have;
by Type year;
if last.year then 
    do;
p_us_=p_us;
vo_=vo;
nosh_=nosh;
    end;
else delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And when summarising the results that I receive, I saw that the data for &lt;STRONG&gt;vo, trading_vol, amihud, vo_&lt;/STRONG&gt; ends up with &lt;EM&gt;&lt;STRONG&gt;0 observation&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;as the proc means indicates below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=have;
title"have";
run;
proc means data=want;
title"want";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="result.PNG" style="width: 418px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47121iA020109F16F29264/image-size/large?v=v2&amp;amp;px=999" role="button" title="result.PNG" alt="result.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also check my logic in my code but cannot find out the reason why it ends up like that, can you please have a look and point me out what should be the possibilities of such a result?&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Jul 2020 08:05:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-when-using-last-type/m-p/669116#M200684</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2020-07-14T08:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Error when using last.type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-when-using-last-type/m-p/669118#M200686</link>
      <description>&lt;P&gt;Your data step keeps only the &lt;EM&gt;very last&lt;/EM&gt; observation of each year for a type. Looks like your variables are always missing on these last observations.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 08:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-when-using-last-type/m-p/669118#M200686</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-14T08:21:09Z</dc:date>
    </item>
  </channel>
</rss>

