IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macro Discussion :

Condition et macro variable


Sujet :

Macro

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    52
    Détails du profil
    Informations personnelles :
    Âge : 50
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 52
    Par défaut Condition et macro variable
    Bonjour,

    J'ai écrit le code ci-dessous. Il doit me permettre de récupérer des tables SAS en fonction de plusieurs critères : Année, trimestre...
    La macro fonctionne (les bibliothèques sont bien créées) mais pas les macro-variables (fica ficb...) . Quand je lance l'étape DATA crea_reg, j'obtiens les message suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    335  data crea_reg;
    336  set &fica. &ficb. &ficc.;
             -
             22
             200
    WARNING: Référence symbolique apparente FICA non traitée.
    WARNING: Référence symbolique apparente FICB non traitée.
    WARNING: Référence symbolique apparente FICC non traitée.
    ERROR: Il n'y a pas de table d'entrée par défaut (_LAST_ is _NULL_).
    ERROR 22-322: Erreur de syntaxe ; syntaxe requise : un nom, une chaîne entre guillemets, ;, END, INDSNAME, KEY, KEYS, NOBS, OPEN,
                  POINT, _DATA_, _LAST_, _NULL_.
     
    ERROR 200-322: Le symbole n'est pas reconnu et sera ignoré.
    ci-joint également le programme sas macro :
    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
    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
    %let tr=2;
    %let an=14;
    %let an1=%eval(&an.-1);
     
    %macro crea_var;
    %if &tr.=1 %then %do;
    	libname sas "W:\AAA01\GEN_AAA01&an.4_DCRE2SAS";
    	libname before "W:\AAA01\GEN_AAA01&an1.C_DCRE2SAS";
    	%let fica=sas.creat&an.01;
    	%let ficb=sas.creat&an.02;
    	%let ficc=sas.creat&an.03;
    	%let ficd=before.creat&an1.10;
    	%let ficj=before.creat&an1.11;
    	%let ficf=before.creat&an1.12;
    	%let ficg=before.creat&an1.01;
    	%let fich=before.creat&an1.02;
    	%let fici=before.creat&an1.03;
    	%let Nta=T1&an.;
    	%let Ntb=T4&an1.;
    	%let Ntc=T1&an1.;
    	%end;
    %else %do;
    	%if &tr.=2 %then %do;
    	libname sas "W:\AAA01\GEN_AAA01&an.7_DCRE2SAS";
    	libname before "W:\AAA01\GEN_AAA01&an1.C_DCRE2SAS";
    	%let fica=sas.creat&an.04;
    	%let ficb=sas.creat&an.05;
    	%let ficc=sas.creat&an.06;
    	%let ficd=sas.creat&an.01;
    	%let ficj=sas.creat&an.02;
    	%let ficf=sas.creat&an.03;
    	%let ficg=before.creat&an1.04;
    	%let fich=before.creat&an1.05;
    	%let fici=before.creat&an1.06;
    	%let Nta=T2&an.;
    	%let Ntb=T1&an.;
    	%let Ntc=T2&an1.;
    	%end;
    %else %do;
    	%if &tr.=3 %then %do;
    	libname sas "W:\AAA01\GEN_AAA01&an.A_DCRE2SAS";
    	libname before "W:\AAA01\GEN_AAA01&an1.C_DCRE2SAS";
    	%let fica=sas.creat&an.07;
    	%let ficb=sas.creat&an.08;
    	%let ficc=sas.creat&an.09;
    	%let ficd=sas.creat&an.04;
    	%let ficj=sas.creat&an.05;
    	%let ficf=sas.creat&an.06;
    	%let ficg=before.creat&an1.07;
    	%let fich=before.creat&an1.08;
    	%let fici=before.creat&an1.09;
    	%let Nta=T3&an.;
    	%let Ntb=T2&an.;
    	%let Ntc=T3&an1.;
    	%end;
    %else %do;
    	%if &tr.=4 %then %do;
    	libname sas "W:\AAA01\GEN_AAA01&an.C_DCRE2SAS";
    	libname before "W:\AAA01\GEN_AAA01&an1.C_DCRE2SAS";
    	%let fica=sas.creat&an.10;
    	%let ficb=sas.creat&an.11;
    	%let ficc=sas.creat&an.12;
    	%let ficd=sas.creat&an.07;
    	%let ficj=sas.creat&an.08;
    	%let ficf=sas.creat&an.09;
    	%let ficg=before.creat&an1.10;
    	%let fich=before.creat&an1.11;
    	%let fici=before.creat&an1.12;
    	%let Nta=T4&an.;
    	%let Ntb=T3&an.;
    	%let Ntc=T4&an1.;
    	%end;
    %end;
    %end;
    %end;
    %mend;
    Merci de votre aide.
    Bien cordialement, ND

  2. #2
    Membre chevronné
    Homme Profil pro
    Consultant Finance/Assurance
    Inscrit en
    Décembre 2013
    Messages
    198
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Consultant Finance/Assurance

    Informations forums :
    Inscription : Décembre 2013
    Messages : 198
    Par défaut
    Bonjour,

    Ce doit être un problème de Local/Global :

    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
    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
     
    %let tr=2;
    %let an=14;
    %let an1=%eval(&an.-1);
     
    %macro crea_var;
     
    %global fica ficb ficc;
     
    %if &tr.=1 %then %do;
    	libname sas "W:\AAA01\GEN_AAA01&an.4_DCRE2SAS";
    	libname before "W:\AAA01\GEN_AAA01&an1.C_DCRE2SAS";
    	%let fica=sas.creat&an.01;
    	%let ficb=sas.creat&an.02;
    	%let ficc=sas.creat&an.03;
    	%let ficd=before.creat&an1.10;
    	%let ficj=before.creat&an1.11;
    	%let ficf=before.creat&an1.12;
    	%let ficg=before.creat&an1.01;
    	%let fich=before.creat&an1.02;
    	%let fici=before.creat&an1.03;
    	%let Nta=T1&an.;
    	%let Ntb=T4&an1.;
    	%let Ntc=T1&an1.;
    	%end;
    %else %do;
    	%if &tr.=2 %then %do;
    	libname sas "W:\AAA01\GEN_AAA01&an.7_DCRE2SAS";
    	libname before "W:\AAA01\GEN_AAA01&an1.C_DCRE2SAS";
    	%let fica=sas.creat&an.04;
    	%let ficb=sas.creat&an.05;
    	%let ficc=sas.creat&an.06;
    	%let ficd=sas.creat&an.01;
    	%let ficj=sas.creat&an.02;
    	%let ficf=sas.creat&an.03;
    	%let ficg=before.creat&an1.04;
    	%let fich=before.creat&an1.05;
    	%let fici=before.creat&an1.06;
    	%let Nta=T2&an.;
    	%let Ntb=T1&an.;
    	%let Ntc=T2&an1.;
    	%end;
    %else %do;
    	%if &tr.=3 %then %do;
    	libname sas "W:\AAA01\GEN_AAA01&an.A_DCRE2SAS";
    	libname before "W:\AAA01\GEN_AAA01&an1.C_DCRE2SAS";
    	%let fica=sas.creat&an.07;
    	%let ficb=sas.creat&an.08;
    	%let ficc=sas.creat&an.09;
    	%let ficd=sas.creat&an.04;
    	%let ficj=sas.creat&an.05;
    	%let ficf=sas.creat&an.06;
    	%let ficg=before.creat&an1.07;
    	%let fich=before.creat&an1.08;
    	%let fici=before.creat&an1.09;
    	%let Nta=T3&an.;
    	%let Ntb=T2&an.;
    	%let Ntc=T3&an1.;
    	%end;
    %else %do;
    	%if &tr.=4 %then %do;
    	libname sas "W:\AAA01\GEN_AAA01&an.C_DCRE2SAS";
    	libname before "W:\AAA01\GEN_AAA01&an1.C_DCRE2SAS";
    	%let fica=sas.creat&an.10;
    	%let ficb=sas.creat&an.11;
    	%let ficc=sas.creat&an.12;
    	%let ficd=sas.creat&an.07;
    	%let ficj=sas.creat&an.08;
    	%let ficf=sas.creat&an.09;
    	%let ficg=before.creat&an1.10;
    	%let fich=before.creat&an1.11;
    	%let fici=before.creat&an1.12;
    	%let Nta=T4&an.;
    	%let Ntb=T3&an.;
    	%let Ntc=T4&an1.;
    	%end;
    %end;
    %end;
    %end;
    %mend;

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    52
    Détails du profil
    Informations personnelles :
    Âge : 50
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 52
    Par défaut çà marche
    Merci pour l'astuce. Je ne connaissais pas...
    Bien cordialement,
    ND

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Condition sur une macro variable
    Par sofisaas dans le forum Macro
    Réponses: 2
    Dernier message: 03/12/2013, 17h14
  2. macro-variable et condition %IF
    Par Misspatate dans le forum Macro
    Réponses: 4
    Dernier message: 20/04/2009, 21h02
  3. [Macro] Macro variables avec condition
    Par bibette dans le forum Macro
    Réponses: 4
    Dernier message: 07/07/2008, 18h09
  4. Condition sur une macro-variable
    Par ash_rmy dans le forum Macro
    Réponses: 2
    Dernier message: 10/06/2008, 21h35
  5. [VBA-E] Macro Variable Caption
    Par ArchiveAgain dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 02/02/2007, 06h20

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo