<?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 Basic Question on Obs= in proc sort in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16757#M3117</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi Keith,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With ref to your reply "OBS= can only be used against the dataset being read in, not the output dataset, this can be in a procedure or datastep."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It may be true for proc but its not true for datastep.&lt;/P&gt;&lt;P&gt;In datastep, you can use OBS= on output datset like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data x(obs=3);&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output dataset X will keep only 3 rows in it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it sounds logical.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am still looking for the reason why OBS= doesnt work in below example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=test&amp;nbsp; out= &lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;test1(obs=3) &lt;/STRONG&gt;&lt;/SPAN&gt;nodupkey;&lt;BR /&gt;by a;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please advise.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Feb 2012 11:55:41 GMT</pubDate>
    <dc:creator>deepb</dc:creator>
    <dc:date>2012-02-28T11:55:41Z</dc:date>
    <item>
      <title>Basic Question on Obs= in proc sort</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16753#M3113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was just going through something and realized a strange usage of Obs dataset option. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was under an impression that OBS=option can be used anywhere with dataset to limit the number of observation but it proved wrong &lt;/P&gt;&lt;P&gt;Consider below example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;input a ;&lt;BR /&gt;datalines;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;1&lt;BR /&gt;3&lt;BR /&gt;45&lt;BR /&gt;26&lt;BR /&gt;34&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=test&amp;nbsp; out= &lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;test1(obs=3) &lt;/STRONG&gt;&lt;/SPAN&gt;nodupkey;&lt;BR /&gt;by a;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In the above code, Obs=3 doesnt limit the number of observations. Can someone please highlight the reason of it as it is really strange for me being beginner in SAS?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Logs below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;37 data test;&lt;/P&gt;&lt;P&gt;38 input a ;&lt;/P&gt;&lt;P&gt;39 datalines;&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.TEST has 9 observations and 1 variables.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.01 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;49 ;&lt;/P&gt;&lt;P&gt;50 run;&lt;/P&gt;&lt;P&gt;51&lt;/P&gt;&lt;P&gt;52 proc sort data=test out= test1 (obs=3) nodupkey;&lt;/P&gt;&lt;P&gt;53 by a;&lt;/P&gt;&lt;P&gt;54 run;&lt;/P&gt;&lt;P&gt;NOTE: There were 9 observations read from the data set WORK.TEST.&lt;/P&gt;&lt;P&gt;NOTE: 2 observations with duplicate key values were deleted.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.TEST1 has 7 observations and 1 variables.&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SORT used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.03 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2012 10:42:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16753#M3113</guid>
      <dc:creator>deepb</dc:creator>
      <dc:date>2012-02-28T10:42:57Z</dc:date>
    </item>
    <item>
      <title>Basic Question on Obs= in proc sort</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16754#M3114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi Obs can onl be used when creating the dataset using datastep&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2012 11:17:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16754#M3114</guid>
      <dc:creator>manojinpec</dc:creator>
      <dc:date>2012-02-28T11:17:38Z</dc:date>
    </item>
    <item>
      <title>Basic Question on Obs= in proc sort</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16755#M3115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi Manoj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I disagree. OBS option can also be used in procedures for limiting the number of observations.&lt;/P&gt;&lt;P&gt;Like In above example in proc sort, i can use obs=option in data=test but it doesnt work with the dataset in out=:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It works here:&lt;/P&gt;&lt;P&gt;proc sort data=test(obs=3)&amp;nbsp; out=test1&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/SPAN&gt;nodupkey;&lt;BR /&gt;by a;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It doesnt work here:&lt;/P&gt;&lt;P&gt;proc sort data=test&amp;nbsp; out= &lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;test1(obs=3) &lt;/STRONG&gt;&lt;/SPAN&gt;nodupkey;&lt;BR /&gt;by a;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so my question is still open.. why obs=option doesnt work with out=test1 dataset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2012 11:27:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16755#M3115</guid>
      <dc:creator>deepb</dc:creator>
      <dc:date>2012-02-28T11:27:20Z</dc:date>
    </item>
    <item>
      <title>Basic Question on Obs= in proc sort</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16756#M3116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi @deepb,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OBS= can only be used against the dataset being read in, not the output dataset, this can be in a procedure or datastep.&lt;/P&gt;&lt;P&gt;In PROC SQL you can use the OUTOBS= option to restrict the number of observations in the output dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Keith &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2012 11:39:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16756#M3116</guid>
      <dc:creator>Keith</dc:creator>
      <dc:date>2012-02-28T11:39:33Z</dc:date>
    </item>
    <item>
      <title>Basic Question on Obs= in proc sort</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16757#M3117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi Keith,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With ref to your reply "OBS= can only be used against the dataset being read in, not the output dataset, this can be in a procedure or datastep."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It may be true for proc but its not true for datastep.&lt;/P&gt;&lt;P&gt;In datastep, you can use OBS= on output datset like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data x(obs=3);&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output dataset X will keep only 3 rows in it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it sounds logical.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am still looking for the reason why OBS= doesnt work in below example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=test&amp;nbsp; out= &lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;test1(obs=3) &lt;/STRONG&gt;&lt;/SPAN&gt;nodupkey;&lt;BR /&gt;by a;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please advise.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2012 11:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16757#M3117</guid>
      <dc:creator>deepb</dc:creator>
      <dc:date>2012-02-28T11:55:41Z</dc:date>
    </item>
    <item>
      <title>Basic Question on Obs= in proc sort</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16758#M3118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi @deepb,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you definitely tried using OBS= against the output dataset, because it certainly doesn't work for me.&lt;/P&gt;&lt;P&gt;e.g. the following code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data class (obs=5);&lt;/P&gt;&lt;P&gt;set sashelp.class;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This creates a log entry that shows "WARNING 70-63: The option OBS is not valid in this context.&amp;nbsp; Option ignored."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The SAS documentation also states it is restricted to input datasets only&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000131154.htm"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000131154.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2012 12:08:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16758#M3118</guid>
      <dc:creator>Keith</dc:creator>
      <dc:date>2012-02-28T12:08:17Z</dc:date>
    </item>
    <item>
      <title>Basic Question on Obs= in proc sort</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16759#M3119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Keith,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apologies, that was my assumption. You are right.&lt;/P&gt;&lt;P&gt;Thanks a lot for the clarification.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2012 12:14:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/16759#M3119</guid>
      <dc:creator>deepb</dc:creator>
      <dc:date>2012-02-28T12:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Question on Obs= in proc sort</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/330421#M62605</link>
      <description>&lt;P&gt;proc sort data=demo(firstobs=3 obs=5) out=demo9;&lt;/P&gt;&lt;P&gt;by patient;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ref:&amp;nbsp;&lt;A href="http://www2.sas.com/proceedings/sugi31/030-31.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi31/030-31.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 09:26:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Basic-Question-on-Obs-in-proc-sort/m-p/330421#M62605</guid>
      <dc:creator>VijayRK1</dc:creator>
      <dc:date>2017-02-07T09:26:27Z</dc:date>
    </item>
  </channel>
</rss>

