SOFTWARE ADVICE

Welcome to Annie's Advice Column

Welcome to my software advice column. Today's advice is regarding the determination of the frequency of any
SAS dataset variable using SAS base software and the macro language.

Featured Dilemma: Frequency of any SAS dataset variable

THE SAS BASE SOFTWARE AND MACRO LANGUAGE

My Varfreq macro will give you the information
needed. This macro is a convenient way to determine
if there are any data issues for any dataset variable and
how many of the observations for this variable are missing within my dataset.

/* VARFREQ MACRO
Parameters needed:
dataset name - dsnams
variable name - varams */

%macro varfreq(dsnams, varams);
proc freq data=&dsnams;
tables &varams/ missprint norow nocol;
title1 "&varams Frequency Report for the &dsnams Dataset";
footnote1 "Created by AMS at Rainbow Software";
run;
%mend varfreq;

proc sort data=mydata; by myvar; run;

%varfreq(mydata, myvar);

How can I determine what occurences
of my variable, myvar are in my SAS dataset, mydata,
and how many times the variable is missing for all records?