<?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: proc print a few observations in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/470006#M70854</link>
    <description>&lt;P&gt;Thank you so much for your time. Much appreciate it.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jun 2018 17:26:53 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-06-13T17:26:53Z</dc:date>
    <item>
      <title>proc print a few observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469962#M70840</link>
      <description>&lt;P&gt;I understand using firstobs=x, and obs=x, to print out all variables for that observations. I am trying to use proc print for several observations that are far from each other in observation numbers. So, for example, if I want observations number 38701, I would do&lt;/P&gt;&lt;P&gt;proc print data=dataset (firstobs=38701, obs=38701).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would anyone know how to print two or three observations that have observations numbers like 38701, 14080, and/or 9631. Thank you for your time in advance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 15:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469962#M70840</guid>
      <dc:creator>kelSAS</dc:creator>
      <dc:date>2018-06-13T15:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: proc print a few observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469966#M70842</link>
      <description>&lt;P&gt;Do you mean filter a list (&lt;STRONG&gt;in &lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;(38701,14080,9631&lt;/STRONG&gt;&lt;/EM&gt;&lt;STRONG&gt;) &lt;/STRONG&gt;in a proc print?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 15:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469966#M70842</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-13T15:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: proc print a few observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469970#M70843</link>
      <description>&lt;P&gt;If you don't want to run multiple PROC PRINTs, you would first need to construct a data set holding the desired observations.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do k=38701, 14080, 9631;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have point=k;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;stop;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=want;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Be sure to include that STOP statement.&amp;nbsp; Without it, the top DATA step turns into an infinite loop.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 15:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469970#M70843</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-06-13T15:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: proc print a few observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469974#M70844</link>
      <description>&lt;P&gt;Maybe a view?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data myView / view=myView;
set sashelp.class;
if _n_ in (13, 12, 4);
run;

proc means data=myView;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jun 2018 15:53:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469974#M70844</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-13T15:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: proc print a few observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469981#M70847</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/152943"&gt;@kelSAS&lt;/a&gt;&amp;nbsp; &amp;nbsp;It's a very interesting question, at-least to me.&amp;nbsp; I wonder why there isn't an option to filter obs within a proc print step. We can concur with the suggestions using 2 step solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like something like where obs in (1,5,8,...........n) ;&lt;/P&gt;&lt;P&gt;when we know the following works,, I would vote for your idea to have some obs or n within proc print to filter using random lists&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data w;
set sashelp.class;
n+1;
run;

proc print data=w;
where n in (1,5,9);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am keen to see an opinion of the sas artist and king&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp; respectively if they have the time &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 16:05:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469981#M70847</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-13T16:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: proc print a few observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469989#M70848</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/152943"&gt;@kelSAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I understand using firstobs=x, and obs=x, to print out all variables for that observations. I am trying to use proc print for several observations that are far from each other in observation numbers. So, for example, if I want observations number 38701, I would do&lt;/P&gt;
&lt;P&gt;proc print data=dataset (firstobs=38701, obs=38701).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would anyone know how to print two or three observations that have observations numbers like 38701, 14080, and/or 9631. Thank you for your time in advance.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I would ask how do you know that you want observations 38701, 14080 and 9631?&lt;/P&gt;
&lt;P&gt;And what happens if the data is sorted or the number of records changes? The observation numbers would or could change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest turning the rule(s) you use to say that you need specific observations into syntax that can use a WHERE statement such as here:&lt;/P&gt;
&lt;PRE&gt;proc print data=sashelp.class;
  Where (sex='F' and age=13)
      or name='John';
run;&lt;/PRE&gt;
&lt;P&gt;OR add the observation number as a variable, obsnum for example,&amp;nbsp;and use a WHERE statement to reference that variable such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where obsnum in (38701, 14080, 9631);&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 16:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469989#M70848</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-13T16:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: proc print a few observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469992#M70849</link>
      <description>&lt;P&gt;Yes! I want to see only those observations printed.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 16:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469992#M70849</guid>
      <dc:creator>kelSAS</dc:creator>
      <dc:date>2018-06-13T16:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: proc print a few observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469995#M70851</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; Sir, I think OP is &lt;U&gt;intuitively&lt;/U&gt; after your&amp;nbsp;&lt;SPAN&gt;obsnum or my demo in one proc print step. If my understanding is right, OP perhaps wants that to happen in one print step.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 16:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/469995#M70851</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-13T16:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: proc print a few observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/470005#M70853</link>
      <description>&lt;P&gt;I think &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;has the right idea using point.&amp;nbsp; This will pull the OBS in the order specified.&amp;nbsp; I would add a variable to ID the OBS number.&amp;nbsp; If a data set REMOVED observations you would need to check _ERROR_ and handle appropriately.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data obsV / view=obsV;
   length _OBS_ 8;
   do point=1000,456,354;
      set sashelp.heart point=point;
      _obs_ = point;
      output;
      end;
   stop;
   run;
proc print n width=min;
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jun 2018 17:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/470005#M70853</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-06-13T17:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: proc print a few observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/470006#M70854</link>
      <description>&lt;P&gt;Thank you so much for your time. Much appreciate it.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 17:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/470006#M70854</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-13T17:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: proc print a few observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/470339#M70870</link>
      <description>&lt;P&gt;Thank you for asking that question. I need to handle outliers properly and when I run 'proc univariate', the output would show the maximum and minimum with observation number and the value of the variable I ran 'proc univariate' with. I could use certain value to limit data that's proc print'ed, but was wondering if I could print several datalines by observation number in one proc print step.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2018 14:51:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/470339#M70870</guid>
      <dc:creator>kelSAS</dc:creator>
      <dc:date>2018-06-14T14:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: proc print a few observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/470340#M70871</link>
      <description>&lt;P&gt;Thank you so much for your active input. I wish there was one step, but your two-step works perfectly.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2018 14:53:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/470340#M70871</guid>
      <dc:creator>kelSAS</dc:creator>
      <dc:date>2018-06-14T14:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: proc print a few observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/470362#M70875</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;: I don't have anything to add to what has already been suggested other than I would create and store a macro (e.g., %printn) if this is a task that one has to repeat. E.g., using&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;'s suggested code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro printn(dsn,obs);
  %let obs = %sysfunc(tranwrd(%quote(&amp;amp;obs.),%str( ),%str(,)));
  data obsV / view=obsV;
    length _OBS_ 8;
    do point=&amp;amp;obs.;
      set &amp;amp;dsn point=point;
      _obs_ = point;
      output;
    end;
    stop;
  run;
  proc print n width=min;
  run;
  proc datasets memtype=view nodetails nolist;
   delete obsV;
  run;
%mend printn;

%printn(sashelp.heart,1000 456 354)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2018 16:08:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/470362#M70875</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-06-14T16:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: proc print a few observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/470365#M70876</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp; Thank you sir for your time. It feels very satisfying to receive thoughtful responses from my most favorite people that I mentioned 2 here +Ksharp(didn;t bother this time as I assumed sleep time in china can be awkward).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyways, the point is although this seems pretty basic in essence to have a more than one step solution and then do a proc print. I kinda really felt intrigued OP's perspective of having this non sequential filter facility enabled within a proc print. (aka IN operator using the obs column)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;encountered a similar situation at my work before I quit to pursue Grad school on a requirement to do list pull for eligibility customers on a waterfall method.&amp;nbsp; Back then I didn't pay much attention. But When i do envision the requirement becoming increasingly common, that facility could be a better utility. -- &amp;gt;my 2 cents.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2018 16:17:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-a-few-observations/m-p/470365#M70876</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-14T16:17:23Z</dc:date>
    </item>
  </channel>
</rss>

