BookmarkSubscribeRSS Feed
UPRETIGOPI
Obsidian | Level 7

Hi there

 

I have a dataset that contains both character and numeric variables. I need to validate the values of both the character and numeric variables including nulls, missing values, the range of values and the outliers (outside the range of values) if there are any.  If anybody can help me with a macro that I can customize to serve my purpose, I would greatly appreciate your kind assistance in this regard. Thank you very much.

 

Chandra

2 REPLIES 2
Reeza
Super User

What are the rules? I'm not understanding what you're trying to do beyond running a proc univariate and/or freq for your datasets. 

 

Proc univariate data= have;
Proc freq data=have;
Run;
ballardw
Super User

Show some example data and what you expect the result to be.

 

Some of this may be doable with custom formats. Here is an example with one character and one numeric variable with known expected values for the character and an expected range for the numeric.

 

proc format library=work;
value expectnum
., 1-50='In range';
value $expectchar
"Bob","Ted","Alice","Carol"='Expected';
run;

data example;
   informat char $8. num best5.;
   input char num;
datalines;
Bob 1
Ted 77
John 43
Carol .
Alice 189
;
run;

proc freq data=example;
   tables char num / missing;
   format char $expectchar. num expectnum.;
run;

 

The proc freq output will show the number of acceptable (in your defined ranges or lists) values and the individual values that are not acceptable.

 

If a numeric value should not be missing, then remove it from the acceptable range. Proc format has a number of ways to expess end points so you will need to determine what may work for you.

 

Outlier you will have to work on as what may be considered an outlier in one data set may not for another. Proc univariate may help as it will show the largest and smallest values along with distribution characteristics that may let you define outlier.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 900 views
  • 0 likes
  • 3 in conversation