BookmarkSubscribeRSS Feed
HenriTheuwissen
Calcite | Level 5
Hi,

How can I use a prompt to run a Process Flow? For instance, if the result of a prompt is value ABC, then run Process Flow 1, if the result is value QPR then run Process Flow 2.

Henri
5 REPLIES 5
SAS_Doctor
Calcite | Level 5
One way is to use the macro values in %if %then %do blocks or to use %include statements or to use dynamic code built depending on the macro values. This is the basics for dynamic SAS programming!!! It's very flexible and a feature that makes SAS stand out as a premier 4 GL tool.
ChrisHemedinger
Community Manager
Have you seen Conditions in EG 4.2 and 4.3?

You can attach a Condition to any node that can be run (task, query, program) and if the condition is met, the node (and all downstream nodes in the flow) will run. If not, the flow stops right there.

You can use a prompt value as a condition (as well as date/time, data value, and in 4.3 we added macro variable value).

Right-click on the first node in your flow and select Condition->Add to see how it works. If you want to pre-empt the entire flow, add a dummy SAS program node (doesn't need anything it) at the start of the flow, and link all subsequent nodes to it (right-click->Link to...). Then add the Condition to that first node. If the condition fails, the entire flow is skipped.

Chris
Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
JohanaOsorio
SAS Employee

Chris, I have a question... to use the condition is very helpful, but when I run the whole flow, all prompts must be filled, even though the condition is based on a previous prompt and it fails. What can I do if I want the prompts to appear conditionally, based on the values on the previous prompts? I don't want all the prompts to appear when I run the flow/project.

I really appreciate your help!

Jirko
Calcite | Level 5

Dear Johana,

in march 2012 you posted a question to Chris about conditional appearing of prompts in SAS: "What can I do if I want the prompts to appear conditionally, based on the values on the previous prompts? I don't want all the prompts to appear when I run the flow/project."

Do you have already an answer or a solution of the problem. I have really exact the sam problem.

SD_SAS_User
Calcite | Level 5

Hi Chris,

 

I know this is a super old thread but I wanted to ask about using SAS prompts for conditional processing and it was the most relevant one that I could find, plus you also seem to know about this!

 

I have an EG project which is a collection of all the week end processing code that we run. I wanted to add some additional code that is only required at month end. I already define a macro variable "month_end" as 1 for the weeks we class as month end and 0 otherwise. I am then using this to conditionally process the month end code:

 

Flow.JPG

 

My question is around the format of the condition that I am creating as I can't quite understand how this works. I created this on my own PC but the project is run by a number of other users as well. When I initially created the condition, I filled in the box like this (or without the & and . on the macro variable name, I think I tried both):

 

 Condition 1.JPG

 

However, that didn't seem to work on my PC and, after a bit of research I added quotes around both the macro variable and the value and it seemed to work. However, when my boss then ran the project it didn't work for him, the condition failed every time and nothing ran. I then changed back to the above on his PC and for some reason that worked.

 

I have no idea what is going on with this. Firstly, do you know which format is correct? Secondly, is there any reason this would differ between two PCs, both, I believe, on SAS EG 7.1?

 

Also, as I have more than one bit of month end code, I read that the flow stops when a condition is failed and downstream code does not run. I have not found this to be the case and have had to add the same condition to all relevant bits of code.

 

Any help on this would be very much appreciated.

 

Thanks,

 

Steph

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 5297 views
  • 0 likes
  • 6 in conversation