BookmarkSubscribeRSS Feed
alepage
Barite | Level 11

Hello, I have been ask a task I never done before and to be honest, I don't know how to handle this problem.

Here's the challenge.

 

A SAS Dataset is provided as well as an XSD file where the type (num, string, date) of each variable is defined, the number of values we can tolerate (ex: nb_value= 0 then missing value for this variable could be acceptable, nb_value = 1 then no missing value are acceptable, min and max value that a variable could take and so on.

 

The idea is to use those criteria to validate the sas dataset.  If the dataset is validated then we can go through the transformation process.

 

otherwise, an error report (a SAS dataset containing for all the variables, the observations which deviate from criteria) .

 

As I never did that task before, I am open to any suggestion how could we carry out this task?

regards,

1 REPLY 1
ballardw
Super User

Without seeing the XSD file I'm not sure if there is any quick and easy way to this. If the structure is clean enough you might be able to build a number of custom formats to display valid/invalid messages. Here's brief example:

 

Proc format library=work;
value $validsex
'M','F'= 'Valid'
'',' ' = 'Unexpected Missing'
other = 'Unexpected value'
;
run;

data example;
   set sashelp.class;
   if name in ('Alfred' 'Judy') then sex='';
   if name in ('Louise' 'Mary' 'Philip') then sex='A';
run;

proc freq data=example;
  tables sex /missing;
  format sex $validsex.;
run;

However if the value of one variable relies on another  then you will have more coding as you would have to take that into account. Which gets into potentially a lot of code depending on complex the relationships may be.

 

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
  • 1 reply
  • 604 views
  • 0 likes
  • 2 in conversation