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 :

Création de colonnes et de contenu dans une macro


Sujet :

Macro

  1. #1
    Nouveau Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2014
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Santé

    Informations forums :
    Inscription : Mars 2014
    Messages : 1
    Points : 1
    Points
    1
    Par défaut Création de colonnes et de contenu dans une macro
    Bonjour,

    j'ai créé une macro pour réaliser une table qui renseigne sur la consommation de médicament lors d’une période cas et lors de 20 périodes témoins (une colonne par médicament à la période t)

    J'ai fait un test avec 3 médicaments et ça fonctionne très bien pour 20 périodes, mais pour la période t1, j'obtiens par exemple:
    C02LA_12 (donc le médicament n°92 dans la liste et pour la période 12) au lieu de NO2CA_1 (le médicament n°292)

    Savez vous d'où vient le problème ?

    Je vous remercie par avance pour votre aide

    voici une partie de la 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
     
    *cree une macro variable par molécule;
    data _NULL_;set atc4;call symput(compress('atc4' || _N_),atc4);run;
    data _NULL_;set atc4;call symput(compress('atc4t1' || _N_),atc4t1);run;
    data _NULL_;set atc4;call symput(compress('atc4t2' || _N_),atc4t2);run;
    data _NULL_;set atc4;call symput(compress('atc4t3' || _N_),atc4t3);run;
    data _NULL_;set atc4;call symput(compress('atc4t4' || _N_),atc4t4);run;
    data _NULL_;set atc4;call symput(compress('atc4t5' || _N_),atc4t5);run;
    data _NULL_;set atc4;call symput(compress('atc4t6' || _N_),atc4t6);run;
    data _NULL_; set atc4;call symput(compress('atc4t7' || _N_),atc4t7);run;
    data _NULL_; set atc4;call symput(compress('atc4t8' || _N_),atc4t8);run;
    data _NULL_; set atc4;call symput(compress('atc4t9' || _N_),atc4t9);run;
    data _NULL_; set atc4; call symput(compress('atc4t10' || _N_),atc4t10);run;
    data _NULL_; set atc4; call symput(compress('atc4t11' || _N_),atc4t11);run;
    data _NULL_; set atc4; call symput(compress('atc4t12' || _N_),atc4t12);run;
    data _NULL_;set atc4; call symput(compress('atc4t13' || _N_),atc4t13);run;
    data _NULL_; set atc4; call symput(compress('atc4t14' || _N_),atc4t14);run;
    data _NULL_; set atc4; call symput(compress('atc4t15' || _N_),atc4t15);run;
    data _NULL_; set atc4; call symput(compress('atc4t16' || _N_),atc4t16);run;
    data _NULL_; set atc4; call symput(compress('atc4t17' || _N_),atc4t17);run;
    data _NULL_; set atc4;call symput(compress('atc4t18' || _N_),atc4t18);run;
    data _NULL_; set atc4; call symput(compress('atc4t19' || _N_),atc4t19);run;
    data _NULL_; set atc4; call symput(compress('atc4t20' || _N_),atc4t20); run;
     
    /*stocke le nombre de molécule*/
     
    data _NULL_;
    set atc4;
    call symput('nombre' , _N_);
    run;
     
    %macro essai(table);
            %do i=290 %to 292;
     
    data test.initiale;
    set test.initiale;
    if atc4=("&&atc4&i") and exp_acc=1 then &&atc4&i =1;else &&atc4&i=0;
    if atc4t1=("&&atc4t1&i") and expo_t1=1 then &&atc4t1&i=1;else &&atc4t1&i=0;
    if atc4t2=("&&atc4t2&i") and expo_t2=1 then &&atc4t2&i=1;else &&atc4t2&i=0;
    if atc4t3=("&&atc4t3&i") and expo_t3=1 then &&atc4t3&i=1;else &&atc4t3&i=0;
    if atc4t4=("&&atc4t4&i") and expo_t4=1 then &&atc4t4&i=1;else &&atc4t4&i=0;
    if atc4t5=("&&atc4t5&i") and expo_t5=1 then &&atc4t5&i=1;else &&atc4t5&i=0;
    if atc4t6=("&&atc4t6&i") and expo_t6=1 then &&atc4t6&i=1;else &&atc4t6&i=0;
    if atc4t7=("&&atc4t7&i") and expo_t7=1 then &&atc4t7&i=1;else &&atc4t7&i=0;
    if atc4t8=("&&atc4t8&i") and expo_t8=1 then &&atc4t8&i=1;else &&atc4t8&i=0;
    if atc4t9=("&&atc4t9&i") and expo_t9=1 then &&atc4t9&i=1;else &&atc4t9&i=0;
    if atc4t10=("&&atc4t10&i") and expo_t10=1 then &&atc4t10&i=1;else &&atc4t10&i=0;
    if atc4t11=("&&atc4t11&i") and expo_t11=1 then &&atc4t11&i=1;else &&atc4t11&i=0;
    if atc4t12=("&&atc4t12&i") and expo_t12=1 then &&atc4t12&i=1;else &&atc4t12&i=0;
    if atc4t13=("&&atc4t13&i") and expo_t13=1 then &&atc4t13&i=1;else &&atc4t13&i=0;
    if atc4t14=("&&atc4t14&i") and expo_t14=1 then &&atc4t14&i=1;else &&atc4t14&i=0;
    if atc4t15=("&&atc4t15&i") and expo_t15=1 then &&atc4t15&i=1;else &&atc4t15&i=0;
    if atc4t16=("&&atc4t16&i") and expo_t16=1 then &&atc4t16&i=1;else &&atc4t16&i=0;
    if atc4t17=("&&atc4t17&i") and expo_t17=1 then &&atc4t17&i=1;else &&atc4t17&i=0;
    if atc4t18=("&&atc4t18&i") and expo_t18=1 then &&atc4t18&i=1;else &&atc4t18&i=0;
    if atc4t19=("&&atc4t19&i") and expo_t19=1 then &&atc4t19&i=1;else &&atc4t19&i=0;
    if atc4t20=("&&atc4t20&i") and expo_t20=1 then &&atc4t20&i=1;else &&atc4t20&i=0;run;

  2. #2
    Expert confirmé
    Avatar de olivier.decourt
    Homme Profil pro
    Formateur R/SAS/statistiques
    Inscrit en
    Avril 2008
    Messages
    2 064
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France

    Informations professionnelles :
    Activité : Formateur R/SAS/statistiques
    Secteur : Conseil

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 064
    Points : 4 478
    Points
    4 478
    Par défaut
    Bonsoir.
    Je ne vais pas répondre à ta question, plutôt te demander pourquoi tant de macro-variables ? Tu es en train de dupliquer l'intégralité de la table ATC4 dans des dizaines de macro-variables. Je pense qu'une solution utilisant des jointures serait beaucoup plus efficace et simple à écrire.
    Comme je n'ai pas vraiment compris le problème (ni ce que tu cherches à faire au final), je n'ai pas de piste à proposer.
    Bon courage.
    Olivier

  3. #3
    Membre éclairé

    Femme Profil pro
    SAS FRANCE - Support Clients France et Europe
    Inscrit en
    Février 2010
    Messages
    289
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : SAS FRANCE - Support Clients France et Europe
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2010
    Messages : 289
    Points : 886
    Points
    886
    Par défaut
    Bonjour,

    Comme le dit Olivier, c'est choquant ces étapes DATA pour déclarer plein de macro-variables. Vu qu'il n'y a aucun filtre de fait dans ces étapes, et qu'elles lisent toutes la même table, une seule étape DATA avec tous les call symput donnerait le même résultat (idem pour 'nombre'). Le fait que le résultat n'est pas celui espéré montre peut-être que la comparaison des valeurs selon le n° d'observation des valeurs n'est peut-être pas la bonne solution ? Effectivement une jointure sera plus efficace que ces comparaisons de valeurs.
    Cordialement,

    --
    Géraldine CADE-DESCHAMPS
    Consultante ▪ Support Clients SAS
    Tel: +33 1 60 62 12 12 ▪ support@sas.com
    www.sas.com/france
    SAS® … THE POWER TO KNOW®

Discussions similaires

  1. Réponses: 0
    Dernier message: 03/04/2014, 14h50
  2. Réponses: 2
    Dernier message: 23/12/2012, 15h46
  3. Nom de Table contenu dans une colonne
    Par bertrounet64 dans le forum Langage SQL
    Réponses: 1
    Dernier message: 30/08/2010, 10h34
  4. Copier une liste de données contenues dans une colonne filtrée
    Par pierreferte dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 21/07/2010, 09h54
  5. Liste des valeurs contenue dans une colonne
    Par TimDe dans le forum Excel
    Réponses: 5
    Dernier message: 15/08/2008, 17h11

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