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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 743 views
  • 0 likes
  • 3 in conversation