Hi everyone,
I have an issue,
I have a macro : Calcul_Defaut_Acheteur_New
who scan day per day a SAS file, keep only specific lines, and at the end save these specifics lines in a unique SAS file.
And for example, to run the macro, I have to do this (date_bal correspond to the month and date_suiv correspond to the whole day in a month ) :
%let date_suiv=20190101|20190102|20190103|20190104|20190105|20190106|20190107|20190108|20190109|20190110|20190111|20190112|20190113|20190114|20190115|20190116|20190117|20190118|20190119|20190120|20190121|20190122|20190123|20190124|20190125|20190126|20190127|20190128|20190129|20190130|20190131;
%let date_bal=20190131; /*january 2019*/
%Calcul_Defaut_Acheteur_New(date=&date_suiv,Per_B2=&date_bal);
But I would like to execute my macro for the whole year.
So instead of doing this :
%let date_suiv=20190101|20190102|20190103|20190104|20190105|20190106|20190107|20190108|20190109|20190110|20190111|20190112|20190113|20190114|20190115|20190116|20190117|20190118|20190119|20190120|20190121|20190122|20190123|20190124|20190125|20190126|20190127|20190128|20190129|20190130|20190131;
%let date_bal=20190131; /*january 2019*/
%Calcul_Defaut_Acheteur_New(date=&date_suiv,Per_B2=&date_bal);
%let date_suiv=20190201|20190202|20190203|20190204|20190205|20190206|20190207|20190208|20190209|20190210|20190211|20190212|20190213|20190214|20190215|20190216|20190217|20190218|20190219|20190220|20190221|20190222|20190223|20190224|20190225|20190226|20190227|20190228;
%let date_bal=20190231; /*february 2019*/
%Calcul_Defaut_Acheteur_New(date=&date_suiv,Per_B2=&date_bal);
/*
etc
*/
%let date_suiv=20191201|20191202|20191203|20191204|20191205|20191206|20191207|20191208|20191209|20191210|20191211|20191212|20191213|20191214|20191215|20191216|20191217|20191218|20191219|20191220|20191221|20191222|20191223|20191224|20191225|20191226|20191227|20191228|20191229|20191230|20191231;
%let date_bal=20191231; /* december 2019*/
%Calcul_Defaut_Acheteur_New(date=&date_suiv,Per_B2=&date_bal);
I thought to do a macro in my macro but I have no idea how to do it.
Someone know how to do ?
thank you
Is your date_SUIV list always all days in the month separated by pipes, or are specific days included?
Some generic references for now are below, But using CALL EXECUTE or a macro loop will work for this.
UCLA introductory tutorial on macro variables and macros
https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/
Tutorial on converting a working program to a macro
This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it 🙂 https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md
Examples of common macro usage - see the example on looping with dates which would allow you to loop through the dates.
https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Ap...
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.