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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.