09-22-2016 03:48 AM
I've created Date_range Prompt named "range".
My goal is to reach values between range_min and range_max using do while loop in macro. I can get values using intnx function inside data step, but i want to use values in several data steps and proc sql's in macro.
Here is the shorter version of my code and the problem is that my code doesn't stop at value of range_max:
%_eg_conditional_dropds(WORK.base_all); %macro radi; %let temp=&range_min; %let limit=&range_max; %put temp=&temp; %put limit=&limit; %do %while("&temp"d<"&limit"d); %_eg_conditional_dropds(WORK.test); data test; format now limit date9.; now=intnx('day',"&temp"d,1); limit="&limit"d; call symput('temp', put(now,date9.)); run; proc append base=work.base_all data=test; quit; %end; %mend; %radi
Example: if i want date range between 01Sep2016 and 30Sep2016, this program stops at 31Oct2016.
I use SAS EG 7.1
09-22-2016 03:58 AM
The macro language is a text processing language, and comparisons will be text comparisons, meaning that the string "02jan2016"d will be considered "bigger" than "01may2016"d!
You would be better off if you stored the raw date values (days from 01jan1960) with format z5. (creating leading zeroes) into your "macro date" variables.
Another trick would be to create a list of dates in a data step, and use call execute to call a macro doing the work for each date.
Need further help from the community? Please ask a new question.