<?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 Is it possible to automatically generate and paste observation counts to the editor? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552836#M9241</link>
    <description>&lt;P&gt;I'm not sure if SAS (or any other program) has this capability but I was wondering if I created a dataset like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and if the generated dataset had 5,000 observations, is it possible to automatically generate a line at the bottom of that code with the number of observations in the dataset like this?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
run;
/* obs = 5000 */&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If not, is it possible to write a macro that I put at the end of every data step that would count the number of observations in that dataset and copy it to the clipboard so that I can just paste /* obs = 5000 */ directly to the editor?&lt;/P&gt;</description>
    <pubDate>Mon, 22 Apr 2019 13:58:06 GMT</pubDate>
    <dc:creator>Ani7</dc:creator>
    <dc:date>2019-04-22T13:58:06Z</dc:date>
    <item>
      <title>Is it possible to automatically generate and paste observation counts to the editor?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552836#M9241</link>
      <description>&lt;P&gt;I'm not sure if SAS (or any other program) has this capability but I was wondering if I created a dataset like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and if the generated dataset had 5,000 observations, is it possible to automatically generate a line at the bottom of that code with the number of observations in the dataset like this?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
run;
/* obs = 5000 */&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If not, is it possible to write a macro that I put at the end of every data step that would count the number of observations in that dataset and copy it to the clipboard so that I can just paste /* obs = 5000 */ directly to the editor?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2019 13:58:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552836#M9241</guid>
      <dc:creator>Ani7</dc:creator>
      <dc:date>2019-04-22T13:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to automatically generate and paste observation counts to the editor?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552866#M9244</link>
      <description>&lt;P&gt;Check LOG :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;791  data air;
792   set sashelp.air;
793  run;

NOTE: There were 144 observations read from the data set SASHELP.AIR.
NOTE: The data set WORK.AIR has 144 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Apr 2019 14:47:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552866#M9244</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-04-22T14:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to automatically generate and paste observation counts to the editor?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552867#M9245</link>
      <description>&lt;P&gt;Right so my question is if there's a way to pull that "144 observations" string into the code editor in a form similar to what is outlined in my original post.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2019 14:50:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552867#M9245</guid>
      <dc:creator>Ani7</dc:creator>
      <dc:date>2019-04-22T14:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to automatically generate and paste observation counts to the editor?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552898#M9253</link>
      <description>&lt;P&gt;With a simple step like that, you can do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
if _n_ = 1 then put "obs=" nobs;
set have nobs=nobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will put a number into the log for copy/pasting even if have is empty.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on the complexity of your actual logic, you may have to count every output and put when the step finishes.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2019 15:14:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552898#M9253</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-22T15:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to automatically generate and paste observation counts to the editor?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552900#M9254</link>
      <description>&lt;P&gt;Copying to the clipboard is not available from code, as in most situations the SAS session won't even have a clipboard (batch mode, or workspace server from SAS Studio or EG).&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2019 15:17:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552900#M9254</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-22T15:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to automatically generate and paste observation counts to the editor?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552906#M9256</link>
      <description>Ah I was afraid of this. Since this answers my question, I am accepting this as a solution.</description>
      <pubDate>Mon, 22 Apr 2019 15:21:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552906#M9256</guid>
      <dc:creator>Ani7</dc:creator>
      <dc:date>2019-04-22T15:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to automatically generate and paste observation counts to the editor?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552980#M9282</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223871"&gt;@Ani7&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The "number of observations read from the last data set that was closed by the previous procedure or DATA step" is contained in the&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=p0t267pk8lwx3en1gn9fywjgni8y.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;SYSNOBS automatic macro variable&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;You can read text from and write text to the clipboard by means of the &lt;A href="https://documentation.sas.com/?docsetId=lestmtsglobal&amp;amp;docsetTarget=n042lomjih6q5un1kescxjmzd30v.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n0iu9dwmh07mhkn1694p7yfmfdsd" target="_blank" rel="noopener"&gt;CLIPBRD access method of the FILENAME statement&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;Code snippets to be submitted can be assigned to a keyboard shortcut in the &lt;A href="http://support.sas.com/documentation/cdl/en/hostwin/69955/HTML/default/p09f1z387baplan1r0744dqujdln.htm#n09fsvngcgmqton1xer8spmj6g0m" target="_blank" rel="noopener"&gt;KEYS window&lt;/A&gt;.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Putting these three ideas together, you could open the KEYS window (press F9 or enter KEYS into the command line [assuming Windows SAS]) and create a new keyboard shortcut, for example Alt F3, as shown below (highlighted):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="clipbrd.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/28893i7084F77349B40854/image-size/large?v=v2&amp;amp;px=999" role="button" title="clipbrd.png" alt="clipbrd.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;(To make this key definition permanent you need write access to your SASUSER.PROFILE.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, after submitting a DATA step like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set sashelp.cars;
where horsepower&amp;gt;100;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(or a corresponding PROC step, e.g. using PROC SQL) you would press the keyboard shortcut (Alt F3 in the example) and then paste the desired text from the clipboard into the Enhanced Editor (or wherever you want).&lt;/P&gt;
&lt;PRE&gt;/* obs = 425 */&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2019 18:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/552980#M9282</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-04-22T18:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to automatically generate and paste observation counts to the editor?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/553002#M9286</link>
      <description>This is potentially exactly what I'm looking for. Is the KEYS window only available for Base SAS and not EG?</description>
      <pubDate>Mon, 22 Apr 2019 18:58:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/553002#M9286</guid>
      <dc:creator>Ani7</dc:creator>
      <dc:date>2019-04-22T18:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to automatically generate and paste observation counts to the editor?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/553009#M9289</link>
      <description>&lt;P&gt;I never use SAS EG, but in his blog Chris Hemedinger suggested to use an external tool called AutoHotkey (which I haven't used either) as a substitute for the missing KEYS window: &lt;A href="https://blogs.sas.com/content/sasdummy/2017/07/17/sas-eg-key-mappings/" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/sasdummy/2017/07/17/sas-eg-key-mappings/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure if this helps, sorry.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2019 19:13:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Is-it-possible-to-automatically-generate-and-paste-observation/m-p/553009#M9289</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-04-22T19:13:45Z</dc:date>
    </item>
  </channel>
</rss>

