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 :

Macro discretisation qui ne fonctionne plus


Sujet :

Macro

  1. #1
    thomahh
    Invité(e)
    Par défaut Macro discretisation qui ne fonctionne plus
    Bonjour,
    voici mon problème :

    J'utilise la macro discretisation du livre "Etude de cas en statistique décisionnelle".

    Elle fonctionnait très bien jusqu'à hier, puis depuis ce matin il n'y a plus moyen de la faire fonctionner. J'ai redémarré SAS, redémarré mon ordinateur mais il n'y a aucun changement.

    Voici le code :
    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
    %INC'C:\Users\tliberti\Desktop\Ampoules\Macro dscrétisation\xmacro.sas';
    %INC'C:\Users\tliberti\Desktop\Ampoules\Macro dscrétisation\treedisc.sas';
    libname BIB 'C:\Users\tliberti\Desktop\Ampoules\Macro dscrétisation\bibformat';
    LIBNAME BIBMACRO 'C:\Users\tliberti\Desktop\Ampoules\Macro dscrétisation';
    OPTIONS SASMSTORE=BIBMACRO MSTORED;
    /**********************************/
    ods output on;
    ods listing;
    %MACRO DISCRETISATION;
    (FICHIER=infos3,TARGET=ctxpc,LISTVAR=dcapital ,FEUILLE=100, PREFIX=_D, BIBFORMAT=BIB)/STORE;
    %LET N=1;
    %LOCAL VAR;
    %LET VAR=%SCAN(&LISTVAR,&N,%STR( ));
    DATA &FICHIER._DISCRET;
       SET &FICHIER (KEEP=ident &TARGET &LISTVAR);
    RUN;
    %DO %WHILE(&VAR^=);
       %TREEDISC( DATA=&FICHIER, DEPVAR=&TARGET, ORDINAL=&VAR,
       OUTTREE=TRD, LEAF=&FEUILLE, MAXDEPTH=1,
    OPTIONS=NOFORMAT, TRACE=NONE);
       %TREEDISC( INTREE=TRD, CODE='ARBRE.CODE');
     
       DATA _NULL_;
         SET trd;
       CALL SYMPUT("nb",_N_);
       RUN;
     
    %IF &NB >2 %THEN %DO;
    /*Test pour éliminer les variables non découpées*/
     
    DATA &FICHIER._DISCRET;
        SET &FICHIER._DISCRET;
        %INC 'ARBRE.CODE';
    	&PREFIX&VAR=NODE_;
    	RUN;
     
    PROC FREQ; TABLES &var * ⌖
    PROC FREQ; TABLES &var * &prefix&var/LIST OUT=modal;
    PROC SORT DATA=modal; BY &prefix&var DESCENDING &var;
    RUN;
     
    DATA plages (KEEP= etiq plage &prefix&var);
     SET modal;
    BY &prefix&var;
    RETAIN etiq;
    LENGTH etiq $92;
    IF FIRST.&prefix&var THEN etiq=" ";
    etiq=COMPRESS(&var)!!" "!!etiq;
    IF LAST.&prefix&var THEN DO;
       IF LENGTH(etiq)>1 THEN plage=COMPRESS(FIRST(etiq)!!" -"!!SUBSTR(etiq,LENGTH(etiq),1));
                          ELSE plage=COMPRESS(etiq);
    OUTPUT;
    END;
    RUN;
     
    DATA format_chaid;
     SET plages END=fin;
    RETAIN etiq2;
    LENGTH etiq2 $92;
    etiq2=" "!!COMPBL(plage)!!' ="'!!COMPBL(etiq)!!'"'!!COMPBL(etiq2);
       IF fin THEN CALL SYMPUT("FORMAT",ETIQ2);
    RUN;
     
     
    PROC FORMAT LIB=&bibformat;
      VALUE &prefix&var._&format;
    RUN;
     
    %END;
    %LET N=%EVAL(&N+1);
    %LET VAR=%SCAN(&LISTVAR,&N,%STR( ));
    %END;
    %END;
    %MEND DISCRETISATION;
    %DISCRETISATION;

    Et voici la LOG:
    1136 %INC'C:\Users\tliberti\Desktop\Ampoules\Macro dscrétisation\xmacro.sas';
    3365 %INC'C:\Users\tliberti\Desktop\Ampoules\Macro dscrétisation\treedisc.sas';
    7247 libname BIB 'C:\Users\tliberti\Desktop\Ampoules\Macro dscrétisation\bibformat';
    NOTE: Libref BIB was successfully assigned as follows:
    Engine: V9
    Physical Name: C:\Users\tliberti\Desktop\Ampoules\Macro dscrétisation\bibformat
    7248 LIBNAME BIBMACRO 'C:\Users\tliberti\Desktop\Ampoules\Macro dscrétisation';
    NOTE: Libref BIBMACRO was successfully assigned as follows:
    Engine: V9
    Physical Name: C:\Users\tliberti\Desktop\Ampoules\Macro dscrétisation
    7249 OPTIONS SASMSTORE=BIBMACRO MSTORED;


    ods output on;
    7255 ods listing;
    7256 %MACRO DISCRETISATION;
    7257 (FICHIER=infos3,TARGET=ctxpc,LISTVAR=dcapital ,FEUILLE=100, PREFIX=_D, BIBFORMAT=BIB)/STORE
    7257 ! ;
    7258 %LET N=1;
    7259 %LOCAL VAR;
    7260 %LET VAR=%SCAN(&LISTVAR,&N,%STR( ));
    7261 DATA &FICHIER._DISCRET;
    7262 SET &FICHIER (KEEP=ident &TARGET &LISTVAR);
    7263 RUN;
    7264 %DO %WHILE(&VAR^=);
    7265 %TREEDISC( DATA=&FICHIER, DEPVAR=&TARGET, ORDINAL=&VAR,
    7266 OUTTREE=TRD, LEAF=&FEUILLE, MAXDEPTH=1,
    7267 OPTIONS=NOFORMAT, TRACE=NONE);
    7268 %TREEDISC( INTREE=TRD, CODE='ARBRE.CODE');
    7269
    7270 DATA _NULL_;
    7271 SET trd;
    7272 CALL SYMPUT("nb",_N_);
    7273 RUN;
    7274
    7275 %IF &NB >2 %THEN %DO;
    7276 /*Test pour éliminer les variables non découpées*/
    7277
    7278 DATA &FICHIER._DISCRET;
    7279 SET &FICHIER._DISCRET;
    7280 %INC 'ARBRE.CODE';
    7281 &PREFIX&VAR=NODE_;
    7282 RUN;
    7283
    7284 PROC FREQ; TABLES &var * ⌖
    7285 PROC FREQ; TABLES &var * &prefix&var/LIST OUT=modal;
    7286 PROC SORT DATA=modal; BY &prefix&var DESCENDING &var;
    7287 RUN;
    7288
    7289 DATA plages (KEEP= etiq plage &prefix&var);
    7290 SET modal;
    7291 BY &prefix&var;
    7292 RETAIN etiq;
    7293 LENGTH etiq $92;
    7294 IF FIRST.&prefix&var THEN etiq=" ";
    7295 etiq=COMPRESS(&var)!!" "!!etiq;
    7296 IF LAST.&prefix&var THEN DO;
    7297 IF LENGTH(etiq)>1 THEN plage=COMPRESS(FIRST(etiq)!!" -"!!SUBSTR(etiq,LENGTH(etiq),1));
    7298 ELSE plage=COMPRESS(etiq);
    7299 OUTPUT;
    7300 END;
    7301 RUN;
    7302
    7303 DATA format_chaid;
    7304 SET plages END=fin;
    7305 RETAIN etiq2;
    7306 LENGTH etiq2 $92;
    7307 etiq2=" "!!COMPBL(plage)!!' ="'!!COMPBL(etiq)!!'"'!!COMPBL(etiq2);
    7308 IF fin THEN CALL SYMPUT("FORMAT",ETIQ2);
    7309 RUN;
    7310
    7311
    7312 PROC FORMAT LIB=&bibformat;
    7313 VALUE &prefix&var._&format;
    7314 RUN;
    7315
    7316 %END;
    7317 %LET N=%EVAL(&N+1);
    7318 %LET VAR=%SCAN(&LISTVAR,&N,%STR( ));
    7319 %END;
    7320 %END;
    ERROR: There is no matching %DO statement for the %END. This statement will be ignored.
    7321 %MEND DISCRETISATION;
    7322 %DISCRETISATION;
    NOTE: Line generated by the invoked macro "DISCRETISATION".
    1 (FICHIER=infos3,TARGET=ctxpc,LISTVAR=dcapital ,FEUILLE=100, PREFIX=_D,
    -
    180
    1 ! BIBFORMAT=BIB)/STORE;

    ERROR 180-322: Statement is not valid or it is used out of proper order.

    WARNING: Apparent symbolic reference LISTVAR not resolved.
    WARNING: Apparent symbolic reference LISTVAR not resolved.
    WARNING: Apparent symbolic reference FICHIER not resolved.
    NOTE: Line generated by the invoked macro "DISCRETISATION".
    3 DATA &FICHIER._DISCRET; SET &FICHIER (KEEP=ident &TARGET &LISTVAR); RUN;
    - -
    22 200
    200
    ERROR 22-322: Syntax error, expecting one of the following: un nom, une chaîne entre guillemets,
    /, ;, _DATA_, _LAST_, _NULL_.

    ERROR 200-322: The symbol is not recognized and will be ignored.

    3 ! DATA &FICHIER._DISCRET; SET &FICHIER (KEEP=ident &TARGET &LISTVAR); RUN;
    -
    22
    WARNING: Apparent symbolic reference FICHIER not resolved.
    NOTE 137-205: Line generated by the invoked macro "DISCRETISATION".
    3 DATA &FICHIER._DISCRET; SET &FICHIER (KEEP=ident &TARGET &LISTVAR); RUN;
    -
    22
    ERROR 22-322: Syntax error, expecting one of the following: un nom, une chaîne entre guillemets,
    ;, END, INDSNAME, KEY, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.

    ERROR 22-322: Syntax error, expecting one of the following: +, =.

    NOTE: Line generated by the invoked macro "DISCRETISATION".
    3 DATA &FICHIER._DISCRET; SET &FICHIER (KEEP=ident &TARGET &LISTVAR); RUN;
    -
    76
    ERROR 76-322: Syntax error, statement will be ignored.

    ERROR: Undeclared array referenced: FICHIER.
    WARNING: Apparent symbolic reference TARGET not resolved.
    WARNING: Apparent symbolic reference LISTVAR not resolved.

    ERROR: Nom FICHIER non attribué.
    NOTE: The SAS System stopped processing this step because of errors.
    NOTE: L'étape DATA used (Total process time):
    real time 0.01 secondes
    cpu time 0.01 secondes


    WARNING: Apparent symbolic reference LISTVAR not resolved.
    ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric
    operand is required. The condition was: &VAR^=
    ERROR: The condition in the %DO %WHILE loop, &VAR^=, yielded an invalid or missing value, . The
    macro will stop executing.
    ERROR: The macro DISCRETISATION will stop executing.
    .

    Merci à celui qui voudras bien m'aider.

  2. #2
    Membre averti
    Homme Profil pro
    Inscrit en
    Janvier 2012
    Messages
    29
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2012
    Messages : 29
    Par défaut
    Bonjour,

    ll faudrait peut-être supprimer le point-virgule après DISCRETISATION en ligne 9.

    Bon courage

  3. #3
    thomahh
    Invité(e)
    Par défaut
    Je l'ai fait déjà. Ca ne change rien du tout.


    Je viens de la retaper entièrement. Toujours le même résultat.

  4. #4
    thomahh
    Invité(e)
    Par défaut
    Bon bah AnalytX,...je n'ai rien fait de spécial, et la macro remarche...JE ne comprends pas du tout ce qu'il s'est passé.

    SAS ...GRRRR

  5. #5
    Modérateur

    Homme Profil pro
    Consultant en Business Intelligence
    Inscrit en
    Février 2011
    Messages
    1 625
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Consultant en Business Intelligence
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2011
    Messages : 1 625
    Par défaut
    Hello;
    Pk veux tu stocker le résultat dans un CATALOGUE?


    J'ai regardé vite fait ton PGM et j'ai deux petites remarques:
    1- le ";" qui a été évoqué auparavant.
    2- il existe un END en trop.
    démarres une nouvelle session SAS et essaies ceci :
    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
     
    %INC'C:\Users\tliberti\Desktop\Ampoules\Macro dscrétisation\xmacro.sas';
    %INC'C:\Users\tliberti\Desktop\Ampoules\Macro dscrétisation\treedisc.sas';
    libname BIB 'C:\Users\tliberti\Desktop\Ampoules\Macro dscrétisation\bibformat';
    LIBNAME BIBMACRO 'C:\Users\tliberti\Desktop\Ampoules\Macro dscrétisation';
    OPTIONS SASMSTORE=BIBMACRO MSTORED;
    /**********************************/
    ods output ON;
    ods listing;
    %MACRO DISCRETISATION
    (FICHIER=infos3,TARGET=ctxpc,LISTVAR=dcapital ,FEUILLE=100, PREFIX=_D, BIBFORMAT=BIB);
    %LET N=1;
    %LOCAL VAR;
    %LET VAR=%SCAN(&LISTVAR,&N,%STR( ));
    DATA &FICHIER._DISCRET;
       SET &FICHIER (KEEP=ident &TARGET &LISTVAR);
    RUN;
    %DO %WHILE(&VAR^=);
       %TREEDISC( DATA=&FICHIER, DEPVAR=&TARGET, ORDINAL=&VAR,
       OUTTREE=TRD, LEAF=&FEUILLE, MAXDEPTH=1,
    OPTIONS=NOFORMAT, TRACE=NONE);
       %TREEDISC( INTREE=TRD, CODE='ARBRE.CODE');
     
       DATA _NULL_;
         SET trd;
       CALL SYMPUT("nb",_N_);
       RUN;
     
    %IF &NB >2 %THEN %DO;
    /*Test pour éliminer les variables non découpées*/
     
    DATA &FICHIER._DISCRET;
        SET &FICHIER._DISCRET;
        %INC 'ARBRE.CODE';
    	&PREFIX&VAR=NODE_;
    	RUN;
     
    PROC FREQ; TABLES &var * ⌖
    PROC FREQ; TABLES &var * &prefix&var/LIST OUT=modal;
    PROC SORT DATA=modal; BY &prefix&var DESCENDING &var;
    RUN;
     
    DATA plages (KEEP= etiq plage &prefix&var);
     SET modal;
    BY &prefix&var;
    RETAIN etiq;
    LENGTH etiq $92;
    IF FIRST.&prefix&var THEN etiq=" ";
    etiq=COMPRESS(&var)!!" "!!etiq;
    IF LAST.&prefix&var THEN DO;
       IF LENGTH(etiq)>1 THEN plage=COMPRESS(FIRST(etiq)!!" -"!!SUBSTR(etiq,LENGTH(etiq),1));
                          ELSE plage=COMPRESS(etiq);
    OUTPUT;
    END;
    RUN;
     
    DATA format_chaid;
     SET plages END=fin;
    RETAIN etiq2;
    LENGTH etiq2 $92;
    etiq2=" "!!COMPBL(plage)!!' ="'!!COMPBL(etiq)!!'"'!!COMPBL(etiq2);
       IF fin THEN CALL SYMPUT("FORMAT",ETIQ2);
    RUN;
     
     
    PROC FORMAT LIB=&bibformat;
      VALUE &prefix&var._&format;
    RUN;
     
    %END;
    %LET N=%EVAL(&N+1);
    %LET VAR=%SCAN(&LISTVAR,&N,%STR( ));
    %END;
    *%END;
    %MEND DISCRETISATION;
    %DISCRETISATION;
    N'oubliez pas de consulter les FAQ SAS et les cours et tutoriels SAS
    N'oubliez pas de mettre votre message à si la solution donnée résout votre problème

  6. #6
    thomahh
    Invité(e)
    Par défaut
    Merci SAM.

    J'ai vu que tu avais enlevé l'option STORE dans ton code. Je l'ai enlevé dans le mien et ça à marché (la macro s'était remise à ne plus marcher).

    Tu me demandes pourquoi je veux la stocker . J'ai juste recopié ce qui avait dans le livre sans trop réfléchir (normalement il n'y aurait pas dû avoir de problème).

  7. #7
    Modérateur

    Homme Profil pro
    Consultant en Business Intelligence
    Inscrit en
    Février 2011
    Messages
    1 625
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Consultant en Business Intelligence
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2011
    Messages : 1 625
    Par défaut
    l'erreur vient du fait que t'essaies de recréer le catalogue ( avec MSTORE), ce qui ne pas possible il faut le supprimer auparavant du répertoire où il est enregistré .
    N'oubliez pas de consulter les FAQ SAS et les cours et tutoriels SAS
    N'oubliez pas de mettre votre message à si la solution donnée résout votre problème

  8. #8
    Invité de passage
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    1
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 1
    Par défaut
    Bonjour à tous,

    Je démarre en macro SAS et j'aimerai bien utiliser cette macro.
    Est ce que quelqu'un peut m'expliquer les différentes étapes pour que je puisse exploiter cette macro ?

    Est ce que je peux utiliser le code tel quel ou est ce qu'il me manque des ressources (formats, autres macros..)

    Merci !

  9. #9
    thomahh
    Invité(e)
    Par défaut
    Salut Wenn. Je te conseil de lire le livre de Stéphane Tufféry "Etude de cas en statistique décisionnelle" ou alors de faire des recherches sur internet. Personnellement, je ne me souviens plus exactement comment je faisais pour l'utiliser.

Discussions similaires

  1. [XL-2013] Une macro pour cacher une colonne qui ne fonctionne plus
    Par DavidCsame dans le forum Macros et VBA Excel
    Réponses: 15
    Dernier message: 02/03/2015, 14h17
  2. Macro qui ne fonctionne plus sur 2010
    Par Charlie3 dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 26/01/2013, 16h29
  3. [WD-2003] Macro qui ne fonctionne plus depuis changement OS
    Par kinto dans le forum VBA Word
    Réponses: 2
    Dernier message: 16/11/2012, 15h06
  4. [XL-2003] Problème avec 2 macros qui fonctionnaient mais qui ne fonctionnent plus
    Par amilka dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 22/03/2010, 08h25
  5. Forum qui ne fonctionne plus
    Par vins25 dans le forum Autres Logiciels
    Réponses: 3
    Dernier message: 18/02/2006, 17h54

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