Sorry, its really not clear to me either, show the test data in the form of a dataset and show what the output should look like. You have one dataset with three rows and for each of those rows you want to extract data into a new dataset? Thats what you seem to be saying, maybe it is based on ID? If so then you can just merge the first dataset onto the second by id and then use the date as you would any other time. Example below (and do notice i correct the SQL code:
data table1; id="A1"; conversion_date="25sep2017"d; output; id="q1"; conversion_date="07aug2017"d; output; run; proc sql; create table PART3 as select A.ID, A.TRANDATE from REPORT7 A left join TABLE1 B on A.ID=B.ID where A.TRANDATE between B.CONVERSION_DATE and today()-1; quit;
It might help to provide an example of your starting data and what is needed at the end, dummy values are fine as long as they illustrate the entire process, Best is to post data step code to create the data so we know all of the actual variable names and types and can write code against your example. Paste the data step code into a code box opened with the forum {I} menu icon as some code pasted into the main message windows here gets reformatted and will not run accurately when copied into a SAS session.
There should be no need that I see from your example for any macro variables.
You should be able to use something like: where (today() - 90) < datevariablename < (today() - 1)
or the le if you don't want strictly less than. If you are using the actual Between clause in SQL the above would work with
between (today() - 90) and (today() - 1)
When you say :
between 06/27/27 and 10/02/17
between 05/09/17 and 10/02/17
What is between those dates? A variable, what is it's name? Is a character variable? If the variable is character than a "between" comparison is likely to fail as 07/15/04 will be between 05/09/17 and 10/02/17 because 07 is after 05 but before 10 in character comparisons.
If the variable is a SAS date then you do not want to use a character comparison value at all and a human readable literal for dates would be in the form '15Jul2017'd.
Or are you trying to do something in a different database like Oracle or DB2?
Sorry, that's not really very clear.
Sorry, its really not clear to me either, show the test data in the form of a dataset and show what the output should look like. You have one dataset with three rows and for each of those rows you want to extract data into a new dataset? Thats what you seem to be saying, maybe it is based on ID? If so then you can just merge the first dataset onto the second by id and then use the date as you would any other time. Example below (and do notice i correct the SQL code:
data table1; id="A1"; conversion_date="25sep2017"d; output; id="q1"; conversion_date="07aug2017"d; output; run; proc sql; create table PART3 as select A.ID, A.TRANDATE from REPORT7 A left join TABLE1 B on A.ID=B.ID where A.TRANDATE between B.CONVERSION_DATE and today()-1; quit;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.