| Date: | Tue, 5 Aug 2008 15:17:05 -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: N and Nmiss |
|
| In-Reply-To: | <6716d5d0808051244j3d70b98fo51e984b26424df0d@mail.gmail.com> |
| Content-Type: | text/plain; charset=ISO-8859-1 |
You could use arrays and the MISSING function but what would be the
fun in that.
I think PROC FREQ is probably best at counting all variable without
you having to know the names or types. Then it is just a matter of
formatting the output into the format you like. I don't know if my
method is acceptable but I seems to be good enough for the test.
data class;
set sashelp.class;
if _n_ in(3,5,7) then call missing(of _character_);
if _n_ in(4,8) then call missing(of _numeric_);
run;
proc format;
value miss ._-.Z = '2' other='1';
value $miss ' ' = '2' other='1';
run;
ods listing close;
ods output oneWayFreqs=OneWayFreqs;
proc freq data=class;
tables _all_ / missing;
format _character_ $miss. _numeric_ miss.;
run;
ods listing;
*proc print;
run;
data Report(keep=Var N Nmiss);
length Var $32;
array _ns[2] N Nmiss;
do until(last.table);
set OneWayFreqs;
by table notsorted;
var = scan(table,-1);
*_ns(input(coalesceC(of F_:),f1.)) = Frequency;
_ns(input(vvaluex(var),F1.)) = Frequency;
end;
run;
proc print;
run;
On 8/5/08, Jeff <zhujp98@gmail.com> wrote:
> the variables are combination of char and numeric,
> THX.
>
> On Tue, Aug 5, 2008 at 3:24 PM, Ya Huang <ya.huang@amylin.com> wrote:
>
> > It's a natural thing for proc tabulate:
> >
> > data class;
> > set sashelp.class;
> > if name='Alice' then age=.;
> > if name in ('Mary','Philip','Robert') then weight=.;
> > run;
> >
> > proc tabulate noseps;
> > var age weight;
> > table age weight, (n='N' nmiss='Nmiss')*f=5.;
> > run;
> >
> > ------------------------------------
> > | | N |Nmiss|
> > |----------------------+-----+-----|
> > |Age | 18| 1|
> > |Weight | 16| 3|
> > ------------------------------------
> >
> >
> >
> > On Tue, 5 Aug 2008 15:15:56 -0400, Jeff <zhujp98@GMAIL.COM> wrote:
> >
> > >I have a table contains about 100 variables (numeric and char)
> > >I want to create a table list varaible name, total count and # of missing
> > >the table shoud look like:
> > >
> > >Variable N Nmiss
> > >var1 13343 222
> > >var2 ------------
> > >----------
> > >
> > >How can I do that?
> > >Thanks.
> > >Jeff
> >
>
|