1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
1 proc sql;
2 CREATE TABLE TableN (variable char(100),valeur int format=BESTX24.4,date int format=Date9.);
NOTE: La table WORK.TABLEN a été créée, avec 0 lignes et 3 col.
3 INSERT INTO TableN VALUES ("x",3,17714);
NOTE: 1 ligne a été insérée dans WORK.TABLEN.
4 INSERT INTO TableN VALUES ("y",4,17714);
NOTE: 1 ligne a été insérée dans WORK.TABLEN.
5 quit;
NOTE: La procédure SQL a utilisé (Durée totale du processus) :
temps réel 0.01 secondes
temps processeur 0.00 secondes
6 %macro evaluer(expression,date);
7 %let nbr=%sysfunc(count(&expression,-))+%sysfunc(count(&expression,+))+%sysfunc(count(&expression,/))+%sysfunc(count(&expression,*));
8 %do j=1 %TO &nbr+1;
9 %let comp&j=%scan(&expression,&j,'+||-||*||/||(||)');
10 proc sql noprint;
11 SELECT valeur INTO :val&j FROM TableN WHERE variable="&&comp&j" AND Date=&date;
12 quit;
13 %let k=%eval(&j-1); %let expression0=&expression;
14 %let valx&j=%sysfunc(compress(%sysfunc(compress(%SYSFUNC(translate("&&val&j",%str( ),%str(,))),%str(%"))),%str( )));
15 %let expression&j=%sysfunc(tranwrd(&&expression&k,&&comp&j,&&valx&j));
16 %end;
17 %let n=%eval(&nbr+1);
18 %let expression=%sysevalf(&&expression&n);
19 &expression
20 %mend;
21 %macro test();
22
23 %IF %evaluer(x+y,17714)=7 %then %do;
24 proc sql;
25 SELECT * FROM bib_sm.data_etp1;
26 quit;
27 %end;
28 %mend;
29 %test;
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
ERREUR: Opérande caractère trouvé dans la fonction %EVAL ou condition %IF là où un opérande numérique est requis. La condition était : &val1+&val2
ERREUR: L'exécution de la macro EVALUER va s'arrêter.
30 %macro test();
31
32 %IF %evaluer(x+y,17714)=7 %then %do;
33 proc sql;
34 SELECT * FROM bib_sm.data_etp1;
35 quit;
36 %end;
37 %mend;
38 %test;
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL1 non traitée.
AVERTISSEMENT: Référence symbolique apparente VAL2 non traitée.
ERREUR: Opérande caractère trouvé dans la fonction %EVAL ou condition %IF là où un opérande numérique est requis. La condition était : &val1+&val2
ERREUR: L'exécution de la macro EVALUER va s'arrêter. |
Partager