0

I have a work table named WORK.WEEK_YEAR_FESTIVITA with two records with dates 08dec2022 and 09dec2022 in the field "HolidayDate" and I would to convert this list in a macro variable like "Elenco_Date = '08dec2022'd,'09dec2022'd" and so on for other possible dates in the table WORK.WEEK_YEAR_FESTIVITA. I tried with this proc SQL:

proc sql noprint; select distinct HolidayDate into : Elenco_Date separated by "'d," from WORK.WEEK_YEAR_FESTIVITA; quit;

%put &Elenco_Date;

but the result IS:

ELENCO_DATE = 08DEC2022'd,09DEC2022;

and not

ELENCO_DATE = '08DEC2022'd,'09DEC2022'd;

as desired

Do you have suggestions?

Thanks

1 Answer 1

0

Create the date literal strings in the column list part of the SELECT statement.

select distinct quote(put(HolidayDate,date9.))||'d'
  into :Elenco_Date separated by ',' 
  from WORK.WEEK_YEAR_FESTIVITA
;

Or you could just store the raw number of days into the macro variable.

select distinct HolidayDate format=6.
  into :Elenco_Date separated by ',' 
  from WORK.WEEK_YEAR_FESTIVITA
;

Since there is no difference between using

where date = "08DEC2022"d

and

where date = 22987
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.