I am trying to subset my dataset based on months, and I want it to loop through the months and create a different dataset for each month. This is my code: %macro SASPLay; %let start = 30JUN2014; %do i=0 %to 10; data _null_; call symputx("mth",put(intnx("MONTHS",input("&start",Date9.),&i,'SAME'),Date9.)); run; %put &mth; data final_&mth; set mockdata; where DATE = '&mth'd; run; %end; %mend; %SASPlay; It gives these error messages: ERROR: Invalid date/time/datetime constant '&mth'd. ERROR: Syntax error while parsing WHERE clause. I am trying to generalise this, because when I use a hardcoded value (e.g. where DATE = '30JUN2014'd; ) it works. I don't know why I can't just swap out the hardcoded value for &mth, giving that &mth shows as 30JUN2014. I also tried just using where DATE = &mth; That doesn't work either.
... View more