Bonjour,
Je me permets de vous contacter car j'ai une erreur bien précise liée à une boucle dans un macro programme.
Dans un premier temps, je créé la table suivante sous SAS :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 data Listing_a_lancer; length CONTRAT_WHERE $50. CONTRAT_TXT $50. LIBELLE_CONTRAT $50. COMPTEUR 8.; infile datalines DLM=','; input CONTRAT_WHERE $ CONTRAT_TXT $ LIBELLE_CONTRAT $ COMPTEUR; format CONTRAT_WHERE $50. CONTRAT_TXT $50. LIBELLE_CONTRAT $50. COMPTEUR 8.; DATALINES; "1005",1005,MPLCL1,1 "1007",1007,MPLCL2,2 "1990",1990,MPLCL3,3 "2030",2030,MPLCL4,4 "2031",2031,MPLCL5,5 "2032",2032,MPLCL6,6 "2033",2033,MPLCL7,7 "2034",2034,MPLCL8,8 ; run;
Si je lance le code suivant, pas de problème :
Par contre, si je lance le même programme avec une boucle, j'obtiens une erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 %global liste_contrats_where; %global liste_contrats_txt; %global libelle_contrat; data _NULL_ ; set Listing_a_lancer; if compteur = 1 then call symput('liste_contrats_where',CONTRAT_WHERE); if compteur = 1 then call symput('liste_contrats_txt',CONTRAT_TXT); if compteur = 1 then call symput('libelle_contrat',LIBELLE_CONTRAT); run; %put &liste_contrats_where. &liste_contrats_txt. &libelle_contrat.;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 options mprint; %global liste_contrats_where; %global liste_contrats_txt; %global libelle_contrat; %macro boucle; %do i = 1 %to 8; /* A changer la borne */ data _NULL_ ; set Listing_a_lancer; if compteur = &i. then call symput('liste_contrats_where',CONTRAT_WHERE); if compteur = &i. then call symput('liste_contrats_txt',CONTRAT_TXT); if compteur = &i. then call symput('libelle_contrat',LIBELLE_CONTRAT);; run; %put &liste_contrats_where. &liste_contrats_txt. &libelle_contrat.; %end; %mend; %boucle();
J'obtiens l'erreur suivante :
180 : impossible de déterminer LINE et COLUMN.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.
ERROR 180-322: Statement is not valid or it is used out of proper order.
Par contre, avec l'option "mprint", j m’aperçois que SAS réalise quand même ce que je veux.
A noter que j'ai absolument besoin des guillemets de la première colonne de la table "Listing_a_lancer".
Un grand merci pour votre aide.
Aurélien
Partager