Created
January 22, 2024 18:41
-
-
Save hdary85/890e4880f60e9bb52356c9f9d89f180f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %macro Calculs_Trimestriels(trimestre); | |
| /* Début de la macro */ | |
| /* Extraction des informations nécessaires de la table */ | |
| data TempData; | |
| set NOM_TABLE; | |
| format DateDepot datetime27.6; | |
| trimestre_date = intnx('quarter', input(put(&trimestre., yymmn6.), yymmn6.), 0, 'b'); | |
| run; | |
| /* 1- Sélection des clients dont l'anniversaire est dans le trimestre fourni */ | |
| proc sql; | |
| create table ClientsAnniversaire as | |
| select * | |
| from TempData | |
| where month(DateNaissanceClient) = month(trimestre_date); | |
| quit; | |
| /* 2- Calcul du total déposé sur 12 mois */ | |
| proc sql; | |
| create table TotalDepose12Mois as | |
| select IDClient, | |
| sum(Montant) as MontantTotal | |
| from TempData | |
| where DateDepot between intnx('quarter', input(put(&trimestre., yymmn6.), yymmn6.), -3, 'b') | |
| and intnx('quarter', input(put(&trimestre., yymmn6.), yymmn6.), 0, 'b') | |
| group by IDClient; | |
| quit; | |
| /* Fin de la macro */ | |
| %mend; | |
| /* Exemple d'utilisation de la macro avec le trimestre 202301 */ | |
| %Calculs_Trimestriels(202301); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment