11-13-2017 10:35 AM - edited 11-13-2017 10:37 AM
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!!
11-13-2017 11:26 AM
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.
11-13-2017 12:30 PM - edited 11-13-2017 12:31 PM
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!
11-13-2017 02:58 PM
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.
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;