DATA Step, Macro, Functions and more

How to proc freq for all variables in a macro

Reply
Super Contributor
Posts: 312

How to proc freq for all variables in a macro

Dear,

I am validating a data set. I want to check for any missing values and possible values  and outliers for each variables in the data set.

I am running proc freq for each variable. I just want to know any better way to do it  as my lab data set  has more than million obs and 100 variables.

 

data one;
input a b $3 c$5;
datalines;
1 a b
2   c
3   
4 b d
5 c e
6 d f
7   g
8 e
;
proc freq;
tables a;
run;

proc freq;
tables b;
run;

proc freq;
tables c;
run;

PROC Star
Posts: 8,145

Re: How to proc freq for all variables in a macro

Posted in reply to knveraraju91

Why not just use:

data one;
  input a b $3 c$5;
  datalines;
1 a b
2   c
3   
4 b d
5 c e
6 d f
7   g
8 e
;
proc freq;
  tables _all_;
run;

Art, CEO, AnalystFinder.com

 

Super User
Posts: 13,293

Re: How to proc freq for all variables in a macro

Posted in reply to knveraraju91

If you have variables that are more of a measurement than a category such as height, weight, monetary values (price/ sale and similar), you might want to look at them in terms of means, deviations and extremes, such as Proc Univariate provides as with "millions of observations" you might find yourself attempting to look through 100,000s of lines in a single table.

 

Or one approach if you are not concerned about any specific single record's value but know the expected or desired range of values is to create custom formats of "valid" range of data values for specific variables. Example:

 

proc format library=work;
value expectedage 
   13 - 16='Valid'
   other = 'Invalid';
run;

proc freq data=sashelp.class;
   tables age;
   format age expectedage.;
run;

Which at least makes output tables easier to interpret in some forms.

 

Respected Advisor
Posts: 2,802

Re: How to proc freq for all variables in a macro

Posted in reply to knveraraju91

Note that in the above replies, no macros are needed. Don't resort to macros unless you are convinced that there is no non-macro solution available. 

--
Paige Miller
Ask a Question
Discussion stats
  • 3 replies
  • 231 views
  • 7 likes
  • 4 in conversation