| Date: | Mon, 17 Mar 2008 03:29:54 -0700 |
| Reply-To: | RolandRB <rolandberry@HOTMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | RolandRB <rolandberry@HOTMAIL.COM> |
| Organization: | http://groups.google.com |
| Subject: | Re: how to count how many missing values in each variable |
|
| Content-Type: | text/plain; charset=ISO-8859-1 |
On Mar 16, 3:49 pm, Properly <irain...@gmail.com> wrote:
> On Mar 16, 7:13 am, datan...@GMAIL.COM ("data _null_,") wrote:
>
>
>
>
>
> > Hi Art,
>
> > Consider using PROC FREQ LEVELS as below. Very little code needed.
>
> > dm 'clear log; clear output;';
> > data have;
> > missing _;
> > input /*list input*/ var1 var2:$1. var3 var4 :$1.
> > /*formatted input*/ var5 1. var6 $1. /*these have all
> > missing values*/;
> > cards;
> > 1 . 3 a
> > 2 3 . b
> > _ 4 5 c
> > 6 . 8 d
> > ;;;;
> > run;
> > proc print;
> > run;
> > ods output nlevels=nlevels;
> > proc freq data=have levels;
> > tables _all_ / noprint;
> > run;
>
> > *if need to make it faster;
> > proc format;
> > value $miss ' '=' ' other='1';
> > value miss ._,.-.z=. other='1';
> > run;
> > ods output nlevels=nlevels;
> > proc freq data=have levels;
> > tables _all_ / noprint;
> > format _numeric_ miss. _character_ $miss.;
> > run;
> > proc print;
> > run;
>
> > On Sat, Mar 15, 2008 at 11:50 PM, Arthur Tabachneck <art...@netscape.net> wrote:
> > > Properly,
>
> > > There are probably a number of ways to accomplish what you want. One way
> > > would be as follows:
>
> > > data have;
> > > input var1 var2 var3;
> > > cards;
> > > 1 . 3
> > > 2 3 .
> > > . 4 5
> > > 6 . 8
> > > ;
>
> > > data _null_;
> > > set have end=eof;
> > > array all (*) _all_;
> > > retain number_missing;
> > > do i=1 to dim(all);
> > > if missing(all(i)) then number_missing+1;
> > > end;
> > > if eof then put number_missing=;
> > > run;
>
> > > Art
> > > ---------
>
> > > On Sat, 15 Mar 2008 21:14:28 -0700, Properly <irain...@GMAIL.COM> wrote:
>
> > > >For example:
>
> > > >Var1 Var2 Var3
> > > >1
> > > >.
> > > >3
> > > >.
> > > >4
> > > >.
> > > >5
> > > >.
> > > >4
> > > >.
> > > >.
> > > >.
> > > >For this dataset, how to write a program to count how many missing
> > > >values for var1, var2 var3? (no matter they are character or numeric
> > > >variable)
>
> > > >Thanks!
>
> Thanks for your reply. I meant that how to get the missing value for
> each variable. Not the total variables.
> Mising_var1 Missing_var2 Missing_var3
> 1 2 1
>
> Thanks again for your help!- Hide quoted text -
>
> - Show quoted text -
You could use my %misscnt variable.
http://www.datasavantconsulting.com/roland/misscnt.sas
|