Help using Base SAS procedures

Assessing Missing/Nulls in character fields

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Assessing Missing/Nulls in character fields

Hi,

I was wondering whether there is an easy way to assess the no. missing/null values in a field?

I use the following for numeric and string variables. Its fine for numeric variables, but the code for string variables returns a frequency table of values, if there is a lot of records and a string ID field the output can be massive. Is there a way to output a report of only the count of the number of missing values for each character variable?

thanks,

/* Asess numeric variables */

proc means data = Datafile n nmiss;

  var _numeric_;

run;

/* Asess categorical variables */

proc freq data = Datafile;

tables  _character_ ;


Accepted Solutions
Solution
‎07-05-2013 01:56 PM
New Contributor
Posts: 2

Re: Assessing Missing/Nulls in character fields

... just in case anyone was wondering!

proc format;

value $miss " "="missing"

other="nomissing";

run;

proc freq data=datafile;

  tables _character_ / missing;

  format _character_ $miss.;

run;

View solution in original post


All Replies
Solution
‎07-05-2013 01:56 PM
New Contributor
Posts: 2

Re: Assessing Missing/Nulls in character fields

... just in case anyone was wondering!

proc format;

value $miss " "="missing"

other="nomissing";

run;

proc freq data=datafile;

  tables _character_ / missing;

  format _character_ $miss.;

run;

Super User
Posts: 10,023

Re: Assessing Missing/Nulls in character fields

data have;
 set sashelp.class;
 if ranuni(-1) lt 0.5 then call missing(name);
 if ranuni(-1) lt 0.5 then call missing(age);
run;

proc sql;
 select cats('nmiss(',name,') as nmiss_',name) into : list separated by ','
  from dictionary.columns 
   where libname='WORK' and memname='HAVE';

 create table want as
  select &list from have;
quit;

Ksharp

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 142 views
  • 0 likes
  • 2 in conversation