Date: Tue, 29 Oct 2002 21:30:28 -0500
Reply-To: "Karl K." <karlstudboy@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Karl K." <karlstudboy@HOTMAIL.COM>
Subject: Re: How to return the rows number of a data set?
I realize I'm PROBABLY quibbling here (and I've DEFINITELY taken this thread
off topic), but your thoughtful (as always) and eminently practical response
doesn't help my nagging concern that the action of sqlobs is logically
inconsistent. You reminded me that the other gotcha is with "into".
First:
> I understand that without "separated by" or a range of mVar names,
> only one row is output into the mVar.
> That would appear to be consistent with having
> &sqlObs = 1
> The issue may be just what &sqlObs is counting...
> It appears to be only rows output......
Sure, if there's an "into". But now remove the "into", and leave the
"noprint" in place. How many rows are output? As near as I can tell, there
is no output whatsoever. So shouldn't sqlobs be 0? But it's not; it's 1.
Second:
> the only context where this might bother me, always seems to work
> proc sql noprint ;
> select something
> into :list separated by ' '
> from somewhere
> where <IwantIt> ;
> %let n_wanted = &sqlobs;
> quit;
> has "so-far" been reliable ! (thank goodness)
>
> Is this because that "separated by ...." forces the output.of more than
one row ?
Are you sure it always works? Before you run the sample program below, form
a hypothesis on what the value of sqlobs is in each of the 6 queries below.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
data one; do i = 1 to 5; output; end; run; /* make a sample dataset */
* run a couple queries;
proc sql;
select i into :listi1-:listi4 from one;
%put &sqlobs;
select i into :listi1-:listi999 from one;
%put &sqlobs;
select i into :listi separated by ' ' from one;
%put &sqlobs;
proc sql noprint;
select i into :listi1-:listi4 from one;
%put &sqlobs;
select i into :listi1-:listi999 from one;
%put &sqlobs;
select i into :listi separated by ' ' from one;
%put &sqlobs;
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Now, logically, am I nuts to think you should get the same value of sqlobs
in each case? Well, as they used to say in Sesame Street, "One of these
things is not like the others."
I beg the groups forgiveness for spending so much time on an issue that has
very little practical consequence in our day-to-day work.
Karl