<?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: Define value to be filled in the empty created created while using &amp;quot;firstobs&amp;quot; function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/705781#M216560</link>
    <description>&lt;P&gt;I think you need to provide example data AND full code.&lt;/P&gt;
&lt;P&gt;The code you show will basically duplicate the value for all rows and nothing should be "blank" unless you reset the variable values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect you may actually be running code with OBS=1 on a data set with two rows of data like this:&lt;/P&gt;
&lt;PRE&gt;data have;
input x @@;
datalines;
1 2 
;

 data want;
   merge have
         have(obs = 1 rename=(x=y));
run;&lt;/PRE&gt;
&lt;P&gt;There is functionally no difference between&lt;/P&gt;
&lt;PRE&gt;data want;
   merge have
              have (rename=(var=newvar))
   ;
run;
/*or*/
data want;
   merge have
              have (firstobs=1 rename=(var=newvar))
   ;
run;&lt;/PRE&gt;
&lt;P&gt;From the documentation:&lt;/P&gt;
&lt;DIV class="xis-eDocBody"&gt;
&lt;DIV class="xis-refDictEntry"&gt;
&lt;P class="xis-shortDescription"&gt;Firstobs Specifies the first row in a data source that SAS processes.&lt;/P&gt;
&lt;P class="xis-shortDescription"&gt;So when you say Firstobs=1 then you are defaulting to using all observations starting with the first, in other words the default behavior of using all the values.&lt;/P&gt;
&lt;P class="xis-shortDescription"&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Mon, 14 Dec 2020 17:29:41 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-12-14T17:29:41Z</dc:date>
    <item>
      <title>Define value to be filled in the empty created created while using "firstobs" function on a column.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/705627#M216512</link>
      <description>&lt;P&gt;When using "firstobs" function on a column it creates a lookahead column because of which empty cells are created(Number depends on the argument used in the lookahead function) at the end of the column. Is there any way I can define the value to be filled in that empty cell?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 10:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/705627#M216512</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2020-12-14T10:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Define value to be filled in the empty created created while using "firstobs" function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/705628#M216513</link>
      <description>&lt;P&gt;Show us your code.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 10:41:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/705628#M216513</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-12-14T10:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Define value to be filled in the empty created created while using "firstobs" function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/705639#M216517</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;data WORK.test;&lt;BR /&gt;merge&lt;BR /&gt;WORK.sample_table&lt;BR /&gt;WORK.sample_table (firstobs=2 keep=SerialNumber rename=(SerialNumber=_SerialNumber));&lt;BR /&gt;/* further processing */&lt;BR /&gt;run;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;After executing the above code 1 empty cell will get created in the last row of the column, now I want to define a certain value to be filled in that empty/null cell. How can I achieve that?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 08:05:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/705639#M216517</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2020-12-17T08:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Define value to be filled in the empty created created while using "firstobs" function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/705643#M216519</link>
      <description>&lt;P&gt;See if you can use this as a template&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input x @@;
datalines;
1 2 3 4 5
;

data want;
   merge have end=z
         have(firstobs = 2 rename=x=_x);
   if z then _x = 999;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Dec 2020 11:55:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/705643#M216519</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-12-14T11:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: Define value to be filled in the empty created created while using "firstobs" function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/705781#M216560</link>
      <description>&lt;P&gt;I think you need to provide example data AND full code.&lt;/P&gt;
&lt;P&gt;The code you show will basically duplicate the value for all rows and nothing should be "blank" unless you reset the variable values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect you may actually be running code with OBS=1 on a data set with two rows of data like this:&lt;/P&gt;
&lt;PRE&gt;data have;
input x @@;
datalines;
1 2 
;

 data want;
   merge have
         have(obs = 1 rename=(x=y));
run;&lt;/PRE&gt;
&lt;P&gt;There is functionally no difference between&lt;/P&gt;
&lt;PRE&gt;data want;
   merge have
              have (rename=(var=newvar))
   ;
run;
/*or*/
data want;
   merge have
              have (firstobs=1 rename=(var=newvar))
   ;
run;&lt;/PRE&gt;
&lt;P&gt;From the documentation:&lt;/P&gt;
&lt;DIV class="xis-eDocBody"&gt;
&lt;DIV class="xis-refDictEntry"&gt;
&lt;P class="xis-shortDescription"&gt;Firstobs Specifies the first row in a data source that SAS processes.&lt;/P&gt;
&lt;P class="xis-shortDescription"&gt;So when you say Firstobs=1 then you are defaulting to using all observations starting with the first, in other words the default behavior of using all the values.&lt;/P&gt;
&lt;P class="xis-shortDescription"&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 14 Dec 2020 17:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/705781#M216560</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-14T17:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Define value to be filled in the empty created created while using "firstobs" function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/706558#M216864</link>
      <description>My bad. I am using firstobs=2 in my code</description>
      <pubDate>Thu, 17 Dec 2020 08:06:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/706558#M216864</guid>
      <dc:creator>Saurabh_Rana</dc:creator>
      <dc:date>2020-12-17T08:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Define value to be filled in the empty created created while using "firstobs" function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/706559#M216865</link>
      <description>&lt;P&gt;Did you try my code above?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 08:08:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Define-value-to-be-filled-in-the-empty-created-created-while/m-p/706559#M216865</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-12-17T08:08:00Z</dc:date>
    </item>
  </channel>
</rss>

