<?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: Show record as blank in last row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/708968#M217919</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile datalines;
input Year $ Month $ Dept1N Dept2N ;
return;
datalines;
2014 1Jun2014 2500 2100 
2014 1Jul2014 2330 2220
2014 1Aug2014 1500 2140 
2014 1Sep2014 2500 2670
2014 1Oct2014 4500 4100 
2014 1Nov2014 2600 7100
;
run;

data want;
 set test end=eof;
 if eof and ^ missing(month) then call missing(month);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 01 Jan 2021 01:02:58 GMT</pubDate>
    <dc:creator>r_behata</dc:creator>
    <dc:date>2021-01-01T01:02:58Z</dc:date>
    <item>
      <title>Show record as blank in last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/708966#M217917</link>
      <description>&lt;P&gt;data test;&lt;BR /&gt;infile datalines;&lt;BR /&gt;input Year $ Month $ Dept1N Dept2N ;&lt;BR /&gt;return;&lt;BR /&gt;datalines;&lt;BR /&gt;2014 1Jun2014 2500 2100 &lt;BR /&gt;2014 1Jul2014 2330 2220&lt;BR /&gt;2014 1Aug2014 1500 2140 &lt;BR /&gt;2014 1Sep2014 2500 2670&lt;BR /&gt;2014 1Oct2014 4500 4100 &lt;BR /&gt;2014 1Nov2014 2600 7100&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;DATA WANT;&lt;BR /&gt;SET TEST;&lt;BR /&gt;IF _N_ = NOBS THEN MONTH EQ '';&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;I want to say that if MONTH in last row is populated, then show it as a blank.&amp;nbsp; In this case the last row showing 1NOV2014 would show a blank.&amp;nbsp; I tried the NOBS function but no success&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 23:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/708966#M217917</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2020-12-31T23:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Show record as blank in last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/708967#M217918</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile datalines;
input Year $ Month $ Dept1N Dept2N ;
return;
datalines;
2014 1Jun2014 2500 2100 
2014 1Jul2014 2330 2220
2014 1Aug2014 1500 2140 
2014 1Sep2014 2500 2670
2014 1Oct2014 4500 4100 
2014 1Nov2014 2600 7100
;
run;

data want;
 set test nobs=nobs curobs=k;
 if k=nobs and not missing(month) then call missing(month);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please use CUROBS, it's better&lt;/P&gt;
&lt;P&gt;Of course, you can use _N_ too:-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set test nobs=nobs ;
 if _n_=nobs and not missing(month) then call missing(month);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Dec 2020 23:38:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/708967#M217918</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-12-31T23:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Show record as blank in last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/708968#M217919</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile datalines;
input Year $ Month $ Dept1N Dept2N ;
return;
datalines;
2014 1Jun2014 2500 2100 
2014 1Jul2014 2330 2220
2014 1Aug2014 1500 2140 
2014 1Sep2014 2500 2670
2014 1Oct2014 4500 4100 
2014 1Nov2014 2600 7100
;
run;

data want;
 set test end=eof;
 if eof and ^ missing(month) then call missing(month);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Jan 2021 01:02:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/708968#M217919</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2021-01-01T01:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Show record as blank in last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/708969#M217920</link>
      <description>&lt;P&gt;The OP's statement of the problem includes (emphasis mine):&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I want to say that &lt;EM&gt;&lt;STRONG&gt;if MONTH in last row is populated, then show it as a blank&lt;/STRONG&gt;&lt;/EM&gt;.&amp;nbsp; In this case the last row showing 1NOV2014 would show a blank.&amp;nbsp; I tried the NOBS function but no success&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This description is a bit misleading, and leads to statements similar to the below, which are a bit redundant:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; if eof and ^ missing(month) then call missing(month);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can just as well use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; if eof then call missing(month);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't see any difference between &lt;EM&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;if MONTH in last row is populated, then show it as a blank"&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;and the unconditional statement &lt;EM&gt;&lt;STRONG&gt;"make month in last row a blank"&lt;/STRONG&gt;&lt;/EM&gt;.&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The only situation in which "if eof and ^missing(month) then call missing(month)" is not redundant would be if the EOF month had initially realized a special missing value (like .A), and you want to avoid making it into a normal missing value.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jan 2021 01:31:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/708969#M217920</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-01-01T01:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Show record as blank in last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/709145#M218007</link>
      <description>&lt;P&gt;No need to mess around with NOBS and _N_, just use END=&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set test end=done;
  if done then
    call missing(month);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or if you are OK with overwriting the existing data, and you want to save some CPU and elapsed time, you can just replace the row in question:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  modify test nobs=nobs point=nobs;
  call missing(month);
  replace;
  stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If your input data set is large, this can save some time.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jan 2021 13:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/709145#M218007</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2021-01-03T13:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Show record as blank in last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/709152#M218011</link>
      <description>&lt;P&gt;Your current code is referencing a variable NOBS that is not defined. To have the data step create a variable with the number of observations you need to add the NOBS= option to the SET statement.&amp;nbsp; The name of the variable to create is what goes after the NOBS=.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WANT;
  SET TEST nobs=NOBS ;
  IF _N_ = NOBS THEN MONTH EQ '';
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Jan 2021 16:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/709152#M218011</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-03T16:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: Show record as blank in last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/709153#M218012</link>
      <description>&lt;P&gt;I would add that, given the purpose of your request, using END= is a much better idea than using NOBS=.&amp;nbsp; &amp;nbsp;For instance, this would fail:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set sashelp.class (obs=10)  nobs=class_size;
  if _n_=class_size then put 'Last name is ' name;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;while this would succeed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set sashelp.class (obs=10)  end=end_of_class ;
   if end_of_class then put 'Last name is ' name;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And this is just the simplest counterexample.&amp;nbsp; There are a lot more situations that would not be as readily apparent.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jan 2021 16:44:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-record-as-blank-in-last-row/m-p/709153#M218012</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-01-03T16:44:45Z</dc:date>
    </item>
  </channel>
</rss>

