LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 7 Jul 2008 13:00:42 -0500
Reply-To:     Mary <mlhoward@avalon.net>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Mary <mlhoward@AVALON.NET>
Subject:      Re: SET with OBS=0
Comments: To: Talbot Michael Katz <topkatz@MSN.COM>
Content-Type: text/plain; charset="iso-8859-1"

TMK,

You can certainly do this with a SQL statement. I just posted this, but I'll do it again as answer to your question; you can grab the count and put it into a macro variable, then ask IF statements about the macro variable. If statements must be contained within a macro to work.

-Mary

proc sql noprint;

select count(*) as count into :count

from responseProfile_set;

quit;

%put &count;

%if &count=0 %then %do;

%end;

%if &count > 0 %then %do;

%end;

----- Original Message ----- From: Talbot Michael Katz To: SAS-L@LISTSERV.UGA.EDU Sent: Monday, July 07, 2008 12:50 PM Subject: SET with OBS=0

Hi.

I was experimenting with the following code in SAS 9.01.01M3P020206 on HPUX:

%let obsn=0; data _null_; set myds (obs=&obsn.) nobs=nobs; put nobs=; call symput ("nobs",nobs); run; %put nobs = &nobs.;

The put statement produced no output and the %put issued a warning that nobs did not resolve. If I change macro variable obsn to 1 then everything works okay. I wanted to use SET with OBS=0 as a way of getting some information, like the number of observations, without actually reading any observation information into the data vector. Obviously, there are alternatives, such as OPEN and ATTRN, but my questions are: Is there a way to get the number of observations from SET and OBS=0 (in other words, did I do something wrong)? What information can you get from SET and OBS=0, if anything?

Thanks!

-- TMK -- "The Macro Klutz"


Back to: Top of message | Previous page | Main SAS-L page