If you could include some sample data and expected output, it will be easier to give you a more specific answer.
Something like the code below will create a macro variable &max_date
containing the maximum value of the column date
from the table mytable
.
proc sql;
select max(date_variable) format=date9. into :max_date
from mytable
;
quit;
If you want the numeric value rather than the formatted value then leave out the format=date9.
If the date
variable is a datetime rather than a date, then you will have to use a datetime specific format, eg datetime23.
You're likely trying to use a formatted value where you require an unformatted one, or are not specifying the formatted value is a literal date value using DT.
Your code is invalid to create a macro variable, assuming your input data set is called dates
and the variable of interest is called min_of_contact_date
the following would get the minimum value into macro variables and allow for usage.
proc sql noprint;
select min(min_of_contact_date) into :min_date
from dates;
select min(min_of_contact_date) format=datetime20. into :min_date_formatted
from dates;
quit;
put &min_date.;
put &min_date_formatted.;
These are equivalent usages:
if min_of_contact_date = "&min_date_formatted"dt;
if min_of_contact_date = &min_date;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.