<?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: is there a way to get note of proc sql after proc sql runs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-get-note-of-proc-sql-after-proc-sql-runs/m-p/58561#M12687</link>
    <description>Hi&lt;BR /&gt;
As already suggested you could use automatically created macro variables, i.e:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
   create table test as&lt;BR /&gt;
   select *&lt;BR /&gt;
   from sashelp.class&lt;BR /&gt;
   ;&lt;BR /&gt;
   %put SQLRC : &amp;amp;sqlrc;&lt;BR /&gt;
   %put sqlobs: &amp;amp;sqlobs;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
You can find documentation at the end of:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/a001360983.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/a001360983.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
    <pubDate>Thu, 28 Apr 2011 13:07:34 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2011-04-28T13:07:34Z</dc:date>
    <item>
      <title>is there a way to get note of proc sql after proc sql runs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-get-note-of-proc-sql-after-proc-sql-runs/m-p/58556#M12682</link>
      <description>when we run proc sql like following: &lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
create table temp as select * from dataset1 where ... ; &lt;BR /&gt;
quit; &lt;BR /&gt;
&lt;BR /&gt;
the note will tell me TABLE temp created with x rows and y columns. &lt;BR /&gt;
&lt;BR /&gt;
how can I get the x and y with out query the temp itself but from some variable that proc sql returns ?</description>
      <pubDate>Wed, 27 Apr 2011 20:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-get-note-of-proc-sql-after-proc-sql-runs/m-p/58556#M12682</guid>
      <dc:creator>kwu</dc:creator>
      <dc:date>2011-04-27T20:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to get note of proc sql after proc sql runs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-get-note-of-proc-sql-after-proc-sql-runs/m-p/58557#M12683</link>
      <description>Hello Kwu,&lt;BR /&gt;
&lt;BR /&gt;
I do not know any variable that proc SQL produces but this is an alternative way of doing this: &lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  create view t as&lt;BR /&gt;
  select name,age &lt;BR /&gt;
  from SASHELP.CLASS&lt;BR /&gt;
;quit; &lt;BR /&gt;
proc SQL noprint;&lt;BR /&gt;
  select COUNT(*) as x into :x&lt;BR /&gt;
  from t&lt;BR /&gt;
;quit;&lt;BR /&gt;
proc SQL noprint;&lt;BR /&gt;
  select COUNT(name) as y into :y&lt;BR /&gt;
  from SASHELP.VCOLUMN &lt;BR /&gt;
  where libname="WORK" and memname="T"&lt;BR /&gt;
;quit;&lt;BR /&gt;
%put rows=&amp;amp;x columns=&amp;amp;y;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
where x,y are in macro variables with the same names.&lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Wed, 27 Apr 2011 20:44:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-get-note-of-proc-sql-after-proc-sql-runs/m-p/58557#M12683</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-04-27T20:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to get note of proc sql after proc sql runs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-get-note-of-proc-sql-after-proc-sql-runs/m-p/58558#M12684</link>
      <description>Here is a way to do it with a data step.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data _null_;&lt;BR /&gt;
	if 0 then set dataset1 nobs=n;&lt;BR /&gt;
	array char{*} _character_;&lt;BR /&gt;
	array num{*} _numeric_;&lt;BR /&gt;
	vars = dim(char) + dim(num);&lt;BR /&gt;
	put "Note: The dataset has " n "observations and " vars "variables.";&lt;BR /&gt;
	stop;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 27 Apr 2011 20:54:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-get-note-of-proc-sql-after-proc-sql-runs/m-p/58558#M12684</guid>
      <dc:creator>polingjw</dc:creator>
      <dc:date>2011-04-27T20:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to get note of proc sql after proc sql runs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-get-note-of-proc-sql-after-proc-sql-runs/m-p/58559#M12685</link>
      <description>You can use the SQLOBS automatic variable.&lt;BR /&gt;
&lt;BR /&gt;
SQLOBS&lt;BR /&gt;
contains the number of rows that were processed by an SQL procedure statement. For example, the SQLOBS macro variable contains the number of rows that were formatted and displayed in SAS output by a SELECT statement or the number of rows that were deleted by a DELETE statement.&lt;BR /&gt;
&lt;BR /&gt;
When the NOPRINT option is specified, the value of the SQLOBS macro variable depends on whether an output table, single macro variable, macro variable list, or macro variable range is created:&lt;BR /&gt;
&lt;BR /&gt;
If no output table, macro variable list, or macro variable range is created, then SQLOBS contains the value 1.&lt;BR /&gt;
If an output table is created, then SQLOBS contains the number of rows in the output table.&lt;BR /&gt;
If a single macro variable is created, then SQLOBS contains the value 1.&lt;BR /&gt;
If a macro variable list or macro variable range is created, then SQLOBS contains the number of rows that are processed to create the macro variable list or range.&lt;BR /&gt;
If an SQL view is created, then SQLOBS contains the value 0.&lt;BR /&gt;
&lt;BR /&gt;
Note:   The SQLOBS automatic macro variable is assigned a value after the SQL SELECT statement executes.</description>
      <pubDate>Wed, 27 Apr 2011 21:25:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-get-note-of-proc-sql-after-proc-sql-runs/m-p/58559#M12685</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2011-04-27T21:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to get note of proc sql after proc sql runs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-get-note-of-proc-sql-after-proc-sql-runs/m-p/58560#M12686</link>
      <description>why not just run proc contents on your table, like&lt;BR /&gt;
proc contents data= your_table out= work.conts varnum;&lt;BR /&gt;
run;&lt;BR /&gt;
You get a report of the details about each column as well as details about the table including number of rows and columns/variables and observations.  You also get all that metadata as table WORK.CONTS&lt;BR /&gt;
Less detail is provided by&lt;BR /&gt;
proc sql noprint ;&lt;BR /&gt;
select nobs, nvar into :nobs, :nvar &lt;BR /&gt;
from dictionary.tables&lt;BR /&gt;
where libname="%upcase(your_lib)"&lt;BR /&gt;
and memname="%upcase(your_data_memname)"&lt;BR /&gt;
;&lt;BR /&gt;
%put your_data has &amp;amp;nobs rows and &amp;amp;nvar columns ;&lt;BR /&gt;
quit ;&lt;BR /&gt;
Notice that this sql queries dictionary.tables rather than your_lib.your_data_memname table.&lt;BR /&gt;
Of course there is no alternative to running the query if you want the shape (nobs and nvar)  of the output table, but you an still use the nobs/nvar query above for the output table&lt;BR /&gt;
(assuming that output table is named work.temp) &lt;BR /&gt;
proc sql noprint ;&lt;BR /&gt;
select nobs, nvar into :nobs, :nvar &lt;BR /&gt;
from dictionary.tables&lt;BR /&gt;
where libname="WORK"&lt;BR /&gt;
and memname="TEMP"&lt;BR /&gt;
;&lt;BR /&gt;
%put work.temp has &amp;amp;nobs rows and &amp;amp;nvar columns ;&lt;BR /&gt;
quit ;</description>
      <pubDate>Thu, 28 Apr 2011 11:06:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-get-note-of-proc-sql-after-proc-sql-runs/m-p/58560#M12686</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-04-28T11:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: is there a way to get note of proc sql after proc sql runs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-get-note-of-proc-sql-after-proc-sql-runs/m-p/58561#M12687</link>
      <description>Hi&lt;BR /&gt;
As already suggested you could use automatically created macro variables, i.e:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
   create table test as&lt;BR /&gt;
   select *&lt;BR /&gt;
   from sashelp.class&lt;BR /&gt;
   ;&lt;BR /&gt;
   %put SQLRC : &amp;amp;sqlrc;&lt;BR /&gt;
   %put sqlobs: &amp;amp;sqlobs;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
You can find documentation at the end of:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/a001360983.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/a001360983.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Thu, 28 Apr 2011 13:07:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-a-way-to-get-note-of-proc-sql-after-proc-sql-runs/m-p/58561#M12687</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2011-04-28T13:07:34Z</dc:date>
    </item>
  </channel>
</rss>

