Hi there,
I came across SQLOBS and tried some codes but the returns are inconsistent (from the logs).
PROC CONTENTS DATA=SASHELP.cars
OUT=CarVars
NOPRINT;
RUN;
PROC SQL NOPRINT;
SELECT *
FROM CarVars;
QUIT;
%PUT &=SQLOBS;
from the docs
from the docs
precisely, to have the N, you need a data output and print from what I just understood, is considered by sas as an output as well as a table creation.
It is just telling you what it did.
With the NOPRINT option set it was smart enough to know it didn't need to keep running the select statement since it wasn't putting the result anywhere. You can still use it to tell the difference between an empty query and one that returns at least on observation.
255 proc sql noprint; 256 select name,sex from sashelp.class where sex='M'; 257 %put &=sqlobs ; SQLOBS=1 258 select name,sex from sashelp.class where sex='XXX'; NOTE: No rows were selected. 259 %put &=sqlobs ; SQLOBS=0
You will see similar results with SELECT ... INTO giving a different count depending whether you use the SEPARATED BY clause or not.
260 select name into :namelist from sashelp.class; 261 %put &=sqlobs &=namelist ; SQLOBS=1 NAMELIST=Alfred 262 select name into :namelist separated by ' ' 263 from sashelp.class where sex='F'; 264 %put &=sqlobs &=namelist ; SQLOBS=9 NAMELIST=Alice Barbara Carol Jane Janet Joyce Judy Louise Mary 265 quit;
using the following code to replace.
PROC SQL ;
create table _null_ as
SELECT *
FROM CarVars;
QUIT;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.