Getting count 0 if no data is available

Reply
Frequent Contributor
Posts: 87

Getting count 0 if no data is available

%put &syserrortext;

data want;
length syserrortext $400;
syserrortext=symget('syserrortext');
run;

PROC SQL  ;
SELECT COUNT(syserrortext) INTO : count FROM want;
QUIT;

there is no error and no data

i am getting count=1


using this code i am able to handle error in want table

if there is no error i am getting blank data but when i am taking count of syserrortext then i am getting count as 1

how to get count as 0 if no data is available

Super Contributor
Posts: 578

Re: Getting count 0 if no data is available

When I copy/paste your code, I get count=0;  What does your log look like?

18     data want;
19     length syserrortext $400;
20     syserrortext=symget('syserrortext');
21     run;

NOTE: The data set WORK.WANT has 1 observations and 1 variables.

NOTE: DATA statement used (Total process time):

  real time       0.05 seconds
  cpu time        0.00 seconds

22   
23   
24   
25     PROC SQL  ;
26     SELECT COUNT(syserrortext) INTO : count FROM want;
27     QUIT;

NOTE: The PROCEDURE SQL printed page 1.

NOTE: PROCEDURE SQL used (Total process time):

  real time       0.00 seconds
  cpu time        0.00 seconds

28   
29     %put Count = &Count;
Count =    0

3

Super Contributor
Posts: 334

Re: Getting count 0 if no data is available

I run the same code in a fresh sas session (ie no errors) and get 0.

EJ

on 9.3

Ask a Question
Discussion stats
  • 2 replies
  • 224 views
  • 0 likes
  • 3 in conversation