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

I can use the COUNT function in Data Validation within DI Studio?

What´s the syntax?

I need to abort the job if the table has more than one record.

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

From the top of my head:

The Data Validation Node creates SAS Data Step code and the rules are applied on row level. If so then you could use the automatic variable _N_ in an expression where you abort the job if: _N_>1

View solution in original post

10 REPLIES 10
Patrick
Opal | Level 21

From the top of my head:

The Data Validation Node creates SAS Data Step code and the rules are applied on row level. If so then you could use the automatic variable _N_ in an expression where you abort the job if: _N_>1

DaveR_SAS
SAS Employee

To follow up on Patrick's suggestion, perhaps this example for a Data Validation transformation will give you an idea of how this transformation can be used:

SAS(R) Data Integration Studio 4.7: User's Guide

DavidCaliman
Calcite | Level 5

Patrick,

I need abort the job too when the table is empty.

When the table has more than one record is working!

So, the table should have only one record for the job does not fail. (_N_ <> 1 did not work!)

Tks.

LinusH
Tourmaline | Level 20

For an empty table, you could use Status Handling instead - where you can specify an action based on if the target table was updated (or not).

Data never sleeps
DavidCaliman
Calcite | Level 5

Thanks for the reply, but I want in the data validation transformation.

LinusH
Tourmaline | Level 20

Why?

Data never sleeps
Patrick
Opal | Level 21

So you need to abort the job when the table exists but has 0 records (and not "more than 1 record"). That's something else.

Can't test it but doesn't the Data Validation node include a Status Handling tab with one of the default conditions being "Table truncated". You could use this one and if truncated then select action "abort all processes".

SAS(R) Data Integration Studio 4.21: User's Guide

P.S: You should always post the DIS version so we can know what's available to you "out-of-the-box".

Quentin
Super User

Or just add the check as a user-written code module?

Is this seen as "bad form" in DI Studio land?  I haven't done much with DI studio besides user-written code, so I'm curious if people often mix DI transformation nodes with user-written nodes.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
Patrick
Opal | Level 21

Best practice is to use user written code only if you can't do it with an existing transformation.

Quentin
Super User

THanks Patrick.  Rather than hijack this thread, I'll start another one relating to pros and cons of mixing the canned transformations with user written code.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 10 replies
  • 4736 views
  • 3 likes
  • 5 in conversation