Macro Variable:
sqlobs
Short Description:
Automatic macro variable. Returns the number of rows processed by an SQL statement.
Scenario Description:
Many a times after creation of a table, we need to take its count and store it in a macro variable.
One approach is to take “select count * from table”.
But this is approach is time consuming.
Alternatively, we can use the automatic macro variable “sqlobs”.
The automatic macro variable SQLOBS is assigned a value after the SQL SELECT statement executes.
We can directly refer the value of this macro variable to store the count.
Example:
data Marks_sub;
input Id Marks;
datalines;
100 50
101 70
102 30
106 40
;
proc sql;
create table Pass as
select
*
From Marks_sub
where Marks > 40;
quit;
%let count=&sqlobs;
%put Number of rows = &count;
Here two rows qualify the criteria and thus are processed by the sql statement.
In log the message comes as mentioned below:
%put Number of rows = &count;
Number of rows = 2
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment