vadnick
asked on
SAS - Program a string variable containing a date
Hello,
I'm pretty new to SAS programming, so forgive me if this question is pretty green...
I want to do something like this:
%let pddata = between '01-jan-2005' and '31-dec-2005';
However, I want to do this so that it generates this variable dynamically using date functions.
Any ideas?
Thanks!
I'm pretty new to SAS programming, so forgive me if this question is pretty green...
I want to do something like this:
%let pddata = between '01-jan-2005' and '31-dec-2005';
However, I want to do this so that it generates this variable dynamically using date functions.
Any ideas?
Thanks!
ASKER
Would you be able to write the exact code?
With my original statement, I can have a line in a proc sql that reads
...
where a.date_of_purchase &pddata
...
Expanded, this is interpretted as
...
where a.date_of_purchase between '01-JAN-2005' and '12-31-2005'
...
So far, I'm able to get the dynamic code to return the following:
...
where a.date_of_purchase between ' 16437' and ' 16801'
...
With my original statement, I can have a line in a proc sql that reads
...
where a.date_of_purchase &pddata
...
Expanded, this is interpretted as
...
where a.date_of_purchase between '01-JAN-2005' and '12-31-2005'
...
So far, I'm able to get the dynamic code to return the following:
...
where a.date_of_purchase between ' 16437' and ' 16801'
...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, that worked perfectly. I'll have to study the code to see how it works.
You are welcome. Let me know if you have any questions.
as in the following:
Data _null_;
date1 = ...
date2 = ...
call Symput('Pddata','between ' || date1 || ' and ' || date2);
run;
. . .
TITLE1 Important Stuff Pertaining to the Period: &Pddata ;