BookmarkSubscribeRSS Feed
RPYee
Quartz | Level 8

I have a project that has several different process flows.  All process flows are filtered by a common date range.  Can I define the date range one time and have it referenced by each of the process flows? 

 

I am using Enterprise Guide GUI and am a novice when it comes to SAS.  I am trying to apply techniques/logic used in other programs.

 

Any help you can provide is appreciated!!

tia 🙂

 

Rita Yee

Project Engineer

FedEx Express

___________________________________
The fact that I ask for help simply means I am inexperienced and under-educated. Please don't assume I am incompetent and uneducated.
4 REPLIES 4
TomKari
Onyx | Level 15

Hi, Rita

 

Glad to see you're persevering with SAS!

 

Prompts are converted into macro variables, which are defined on the SAS server that your code is executed on. I don't have any way to test it, but I believe that as long as your different process flows are using the same SAS server, and it's not being reset, your macro variable definitions should remain active.

 

Make sure that if you have the option you select that the prompt results are "global" and that they should be "used by all of the programs".

 

If it was me, I'd set up a quick test to confirm.

 

Tom

RPYee
Quartz | Level 8

Thanks for your help Tom! I am so very new to SAS and am trying to find my way around without a map 😉

My reports will take the previous week data results and compare them to the average of the previous 13 weeks.  We have a date table that assigns day number, week number, month number, etc to each operating day.  My first step is to pass the current date to that table to retrieve the current “week number”.   I then use that result to calculate the input parameters for the remaining processes, with the “Starting Week Number” = Current week – 14 and the “Ending Week Number” = Current week – 1.  Right now, I have to change the filter for the other 5 or 6 process flows.  I’d like to run the first process flow and have the remaining process flows reference the results.  I am using the same server for all of the process flows, but I have no clue how to reference anything stored there and I honestly don’t think I am writing anything to it.  We typically only have “read” capability, so anything returned would be local…

 

If you can think of a better way for me to handle the process, I’m certainly open to suggestions!

Rita

___________________________________
The fact that I ask for help simply means I am inexperienced and under-educated. Please don't assume I am incompetent and uneducated.
TomKari
Onyx | Level 15

Hi, Rita

 

It's hard to tell exactly what you need from your post, so I've written a short program that may give an example of some of the stuff you need.

 

I created a date prompt named "Date_Prompt", and ticked the "Use prompt value throughout project" box.

 

This program does some manipulation with the date, and then in a different step uses it to select records. Take a look at the program, and try running it, and that will probably bring up a bunch more questions.

 

Note there are SAS functions DAY, MONTH, and YEAR that return those respective values from a SAS date value.

 

Tom

 

 

data _null_;

/* Get the value of the prompt...treat it as a character string */
DV = "&Date_Prompt.";

/* Convert the character string date to a SAS date value */
Date_Number = input(DV, date9.);
/* This would have worked also...
Date_Number = input("&Date_Prompt.", date9.);
*/

/* This will be the same number, but with a format applied, so it looks like a date when printed */
Date_Number_Formatted = Date_Number;
format Date_Number_Formatted date.;

/* Write all three values to the log */
putlog DV= Date_Number= Date_Number_Formatted=;

/* Set up a global macro variable to use in another step */
%global Date_To_Match;

/* Set the date to a week earlier than the prompt */
Numeric_Date_To_Match = Date_Number - 7;

/* Write it to the log */
/* Should be one week earlier than you specified in your prompt */
putlog Numeric_Date_To_Match=;

/* Store it in the macro variable */
call symput("Date_To_Match", put(Numeric_Date_To_Match, best15.));

run;

/* Now run a PROC SQL as a different step, using the macro variable we just created */
/* 1Mar2004 will find a match, so enter a date of 8Mar2004 when prompted */
proc sql;
create table work.Extract as
select * from sashelp.stocks
where Date = &Date_To_Match.;
quit;
cbrook
Fluorite | Level 6
Tom, thank you for your very clear help with the code for this question. With a few adjustments, I think I will be able to capture what I need and pass it to name my exported files, even when my query does not turn up any rows.
Rita, thank you for raising this topic. I've been looking for a solution like this for passing the user entry so that I can reference it during the export.

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!

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.

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
  • 4 replies
  • 5519 views
  • 2 likes
  • 3 in conversation