Help using Base SAS procedures

blank value not counted as null value

Accepted Solution Solved
Reply
Regular Contributor
Posts: 186
Accepted Solution

blank value not counted as null value

Hi,

I have a table that contains only alphanumerical values. The column Info1 contains value that are blank (empty).

I usually use the following procedure to count null values in a table, but for this table the result returned is 0, but I see that some values are blank.

proc sql;
select count(Info1) as i from table1

where Info1 is null
;quit;

I also tried this but it also return 0 :

proc sql;
select count(Info1) as i from table1

where Info1=''
;quit;

What am I doing wrong?

Thank you for your help.


Accepted Solutions
Solution
‎07-19-2012 05:29 PM
Respected Advisor
Posts: 4,649

Re: blank value not counted as null value

COUNT(info1) counts non-missing info1 values. Use COUNT(*) instead. - PG

PG

View solution in original post


All Replies
Solution
‎07-19-2012 05:29 PM
Respected Advisor
Posts: 4,649

Re: blank value not counted as null value

COUNT(info1) counts non-missing info1 values. Use COUNT(*) instead. - PG

PG
Respected Advisor
Posts: 3,124

Re: blank value not counted as null value

PG is dead on this. Count() has tricked me when I first started using Proc SQL. In comparison, sum() is more predictable.

proc sql;
select sum(missing(Info1)) as i from table1

;quit;

Haikuo

Regular Contributor
Posts: 186

Re: blank value not counted as null value

Thank you both for this precision.

Regards.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 1074 views
  • 3 likes
  • 3 in conversation