Help using Base SAS procedures

counting the missing character and numeric obs

Reply
Regular Contributor
Posts: 229

counting the missing character and numeric obs

Hi i have a data set

data d;
input name $ age;
cards;
23 nani
45 rahul
34 muni

Now i want the no of missing and no missing observations in that obseravions

Message was edited by: Main

Message was edited by: Main Message was edited by: Main
Respected Advisor
Posts: 3,799

Re: counting the missing character and numeric obs

[pre]
* Test data;
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;

* group data as missing or non-missing;
proc format;
value miss ._-.Z = '2' other='1';
value $miss ' ' = '2' other='1';
run;
* count;
ods listing close;
proc freq data=class;
tables _all_ / missing;
format _character_ $miss. _numeric_ miss.;
ods output oneWayFreqs=OneWayFreqs;
run;
ods listing;

* prepare data for display;
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(vvaluex(var),F1.)) = Frequency;
end;
run;
proc print;
run;
[/pre]
Ask a Question
Discussion stats
  • 1 reply
  • 84 views
  • 0 likes
  • 2 in conversation