Date: Tue, 21 Oct 2008 17:30:54 -0500
Reply-To: "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Subject: Re: how to output number of missing values of a text variable on
a table?
In-Reply-To: <9afa2a6f-df2f-4d19-9a55-b7b1b98a76fb@k30g2000hse.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Using the MISSING function this can be simplified somewhat.
proc sql;
select catx(' ','sum(missing(',name,')) as', name)
into :syntax separated by ", "
from dictionary.columns
where Libname = "WORK" AND MemName = "MISSING" ;
%put NOTE: GENERATED SYNTAX: %bquote(&syntax);
select &Syntax
from Missing;
quit;
On 10/21/08, Haris <Karovaldas@gmail.com> wrote:
> How about something like this:
>
> data missing ;
> input a 1 b$ 3 c 5 ;
> cards ;
> 1 a 1
> 2 . 2
> 3 a .
> . a 4
> 5 a 5
> 6 . .
> . a 7
> 8 a .
> 9 . 9
> ;
>
> proc sql ;
> select case
> when type='num' then 'sum(' || name || '= . ) as ' || name
> when type='char' then 'sum(' || name || "= '' ) as " || name
> end
> into :syntax separated by ", "
> from dictionary.columns
> where Libname = "WORK" AND MemName = "MISSING" ;
> quit ;
>
> proc sql ;
> select &Syntax
> from Missing ;
> quit ;
>
|