BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
abmitch95
Calcite | Level 5

Working with a wide dataset of 500+ variables, need to make sure all values in each row fall within their respective domains. Right now I am using a brute force approach of typing an if then statement that prints the study id, variable name, and value if the value falls outside of the domain:

 

data _null_;
set tmp2.bq_module_3;
file print;

if TQ301 not in (1:5,88,99) then put STUDYID 'TQ301 ' TQ301;

if TQ302 not in (1:10) then put STUDYID 'TQ302 ' TQ302;

if TQ303 not in (1:1000) then put STUDYID 'TQ303 ' TQ303;

run;

 

What I'd like is a program that will only require me to enter the domain for each variable, something like:

 

TQ301 DOMAIN = (1:5, 88, 99, .)

TQ302 DOMAIN = (1:10)

TQ303 DOMAIN = (1:1000)

 

For TQ301-TQ303 do;

if [value] not in [domain] then print STUDYID 'variable name' [value];

 

Output would look like this:

 

STUDYNO TQ301 6

STUDYNO TQ302 11

STUDYNO TQ303 1001 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Make a Hash Table to hold these domain. and CHECK it in data step.


View solution in original post

2 REPLIES 2
ballardw
Super User

Without seeing an example of your data I really wonder about 3 "study identification" variables on a single record. Do you mean that you have data as such that one record may have data from 3 (or possibly more) studies?

 

I will submit that negative definitions are also a bit weak as 1001 is only yielding a result of TQ303 because it is overwriting the values your code assigned in the first two conditions.

 

Can you provide some example data of those variables? I suspect there may be a way to do this with a format but my initial approach would require only one of your variables TQ301, TQ302 and TQ303 to be defined (not missing) on each record.

 

Also the way your PUT statements are structured it looks you have a variable named studyid or is that a typo for generating your example desired output of "STUDYNO"???

Ksharp
Super User

Make a Hash Table to hold these domain. and CHECK it in data step.


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
  • 490 views
  • 1 like
  • 3 in conversation