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

SAS Base Discussion :

Format pour des variables caractères


Sujet :

SAS Base

  1. #1
    Membre régulier
    Inscrit en
    Mai 2007
    Messages
    158
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 158
    Points : 71
    Points
    71
    Par défaut Format pour des variables caractères
    Bonjour, j'ai besoin de votre aide, en effet les variables nom de bureau ne retourne pas le nom en entier, je pense que c'est un problème de longueur de caractère puisque par exemple pour grenoble gambetta, il me retourne seulement grenoble gambet. Est ce que quelqu'un a une petite idée??
    Voici mon 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
    data base.fichier_global;
    set base.fichier_global;
    attrib nom_bureau length =$UPCASE10.;
    if code_bureau="0101" then nom_bureau="BOURG EN BRESSE";
    else if code_bureau="0102" then nom_bureau="OYONNAX";
    else if code_bureau="0103" then nom_bureau="BELLEY";
    else if code_bureau="0104" then nom_bureau="MONTLUEL";
    else if code_bureau="0105" then nom_bureau="AMBERIEU";
    else if code_bureau="0501" then nom_bureau="GAP";
    else if code_bureau="0503" then nom_bureau="BRIANCON";
    else if code_bureau="0701" then nom_bureau="ANNONAY";
    else if code_bureau="0702" then nom_bureau="TOURNON";
    else if code_bureau="0704" then nom_bureau="AUBENAS";
    else if code_bureau="2601" then nom_bureau="VALENCE";
    else if code_bureau="2602" then nom_bureau="ROMANS SUR ISERE";
    else if code_bureau="2603" then nom_bureau="MONTELIMAR";
    else if code_bureau="2604" then nom_bureau="VALENCE CENTRE";
    else if code_bureau="3801" then nom_bureau="VIENNE";
    else if code_bureau="3802" then nom_bureau="MEYLAN";
    else if code_bureau="3803" then nom_bureau="ECHIROLLES";
    else if code_bureau="3804" then nom_bureau="VOIRON";
    else if code_bureau="3805" then nom_bureau="BOURGOIN JALLIEU";
    else if code_bureau="3806" then nom_bureau="SASSENAGE";
    else if code_bureau="3807" then nom_bureau="PEAGE DE ROUSSILLON";
    else if code_bureau="3808" then nom_bureau="PONTCHARRA";
    else if code_bureau="3809" then nom_bureau="ST MARCELLIN";
    else if code_bureau="3810" then nom_bureau="ST EGREVE";
    else if code_bureau="3811" then nom_bureau="VIZILLE";
    else if code_bureau="3812" then nom_bureau="LA TOUR DU PIN";
    else if code_bureau="3813" then nom_bureau="GRENOBLE";
    else if code_bureau="3814" then nom_bureau="GRENOBLE GAMBETTA";
    else if code_bureau="4201" then nom_bureau="ST ETIENNE BELLEVUE";
    else if code_bureau="4202" then nom_bureau="ROANNE";
    
    RUN;

  2. #2
    Membre émérite

    Homme Profil pro
    Consultant en Business Intelligence
    Inscrit en
    Mars 2005
    Messages
    1 364
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

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

    Informations forums :
    Inscription : Mars 2005
    Messages : 1 364
    Points : 2 329
    Points
    2 329
    Par défaut
    Bonjour,

    Je ne connais pas le type $upcase10.
    attrib nom_bureau length =$UPCASE10.;

    essaye format nom_bureau $20.;

    Cordialement
    Consultez les FAQs et les anciens postes avant de poser vos questions. Merci

  3. #3
    Membre régulier
    Inscrit en
    Mai 2007
    Messages
    158
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 158
    Points : 71
    Points
    71
    Par défaut
    Non ca ne fonctionne pas non plus j'avais dejà essayé, il me manque toujours la fin de mon nom

  4. #4
    Membre émérite

    Homme Profil pro
    Consultant en Business Intelligence
    Inscrit en
    Mars 2005
    Messages
    1 364
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

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

    Informations forums :
    Inscription : Mars 2005
    Messages : 1 364
    Points : 2 329
    Points
    2 329
    Par défaut
    Bonjour,

    Je pense que le problème est lié à la taille de la variable.

    Essaye
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    format nom_bureau $20.; 
    ou
    format nom_bureau $4.;
    Cordialement
    Consultez les FAQs et les anciens postes avant de poser vos questions. Merci

  5. #5
    Membre régulier
    Inscrit en
    Mai 2007
    Messages
    158
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 158
    Points : 71
    Points
    71
    Par défaut
    Moi aussi je pensais que ca venais de là, mais même en mettant un format $40. mes noms n'apparaissent pas en entier!!! Je ne sais pas comment faire là,

  6. #6
    Membre émérite

    Homme Profil pro
    Consultant en Business Intelligence
    Inscrit en
    Mars 2005
    Messages
    1 364
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

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

    Informations forums :
    Inscription : Mars 2005
    Messages : 1 364
    Points : 2 329
    Points
    2 329
    Par défaut
    c'est possible d'avoir le code
    Consultez les FAQs et les anciens postes avant de poser vos questions. Merci

  7. #7
    Membre régulier
    Inscrit en
    Mai 2007
    Messages
    158
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 158
    Points : 71
    Points
    71
    Par défaut
    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
    data base.fichier_global;
    set base.fichier_global;
    attrib nom_bureau format=$40.;
    if code_bureau="0101" then nom_bureau="BOURG EN BRESSE";
    else if code_bureau="0102" then nom_bureau="OYONNAX";
    else if code_bureau="0103" then nom_bureau="BELLEY";
    else if code_bureau="0104" then nom_bureau="MONTLUEL";
    else if code_bureau="0105" then nom_bureau="AMBERIEU";
    else if code_bureau="0501" then nom_bureau="GAP";
    else if code_bureau="0503" then nom_bureau="BRIANCON";
    else if code_bureau="0701" then nom_bureau="ANNONAY";
    else if code_bureau="0702" then nom_bureau="TOURNON";
    else if code_bureau="0704" then nom_bureau="AUBENAS";
    else if code_bureau="2601" then nom_bureau="VALENCE";
    else if code_bureau="2602" then nom_bureau="ROMANS SUR ISERE";
    else if code_bureau="2603" then nom_bureau="MONTELIMAR";
    else if code_bureau="2604" then nom_bureau="VALENCE CENTRE";
    else if code_bureau="3801" then nom_bureau="VIENNE";
    else if code_bureau="3802" then nom_bureau="MEYLAN";
    else if code_bureau="3803" then nom_bureau="ECHIROLLES";
    else if code_bureau="3804" then nom_bureau="VOIRON";
    else if code_bureau="3805" then nom_bureau="BOURGOIN JALLIEU";
    else if code_bureau="3806" then nom_bureau="SASSENAGE";
    else if code_bureau="3807" then nom_bureau="PEAGE DE ROUSSILLON";
    else if code_bureau="3808" then nom_bureau="PONTCHARRA";
    else if code_bureau="3809" then nom_bureau="ST MARCELLIN";
    else if code_bureau="3810" then nom_bureau="ST EGREVE";
    else if code_bureau="3811" then nom_bureau="VIZILLE";
    else if code_bureau="3812" then nom_bureau="LA TOUR DU PIN";
    else if code_bureau="3813" then nom_bureau="GRENOBLE";
    else if code_bureau="3814" then nom_bureau="GRENOBLE GAMBETTA";
    else if code_bureau="4201" then nom_bureau="ST ETIENNE BELLEVUE";
    else if code_bureau="4202" then nom_bureau="ROANNE";
    else if code_bureau="4203" then nom_bureau="ANDREZIEUX BOUTHEON";
    else if code_bureau="4204" then nom_bureau="ST ETIENNE BERGSON";
    else if code_bureau="4205" then nom_bureau="ST CHAMOND";
    else if code_bureau="4206" then nom_bureau="RIVE DE GIER";
    else if code_bureau="4207" then nom_bureau="FIRMINY";
    else if code_bureau="4209" then nom_bureau="MONTBRISON";
    else if code_bureau="4210" then nom_bureau="CHARLIEU";
    else if code_bureau="4211" then nom_bureau="FEURS";
    else if code_bureau="4301" then nom_bureau="LE PUY";
    else if code_bureau="4302" then nom_bureau="BRIOUDE";
    else if code_bureau="6901" then nom_bureau="CHAMPAGNE AU MT D'OR";
    else if code_bureau="6902" then nom_bureau="ST BONNET DE MURE";
    else if code_bureau="6903" then nom_bureau="LYON GAMBETTA";
    else if code_bureau="6904" then nom_bureau="VENISSIEUX";
    else if code_bureau="6905" then nom_bureau="VILLEURBANNE";
    else if code_bureau="6906" then nom_bureau="BRON";
    else if code_bureau="6907" then nom_bureau="OULLINS";
    else if code_bureau="6909" then nom_bureau="CALUIRE ET CUIRE";
    else if code_bureau="6910" then nom_bureau="VILLEFRANCHE";
    else if code_bureau="6911" then nom_bureau="FRANCHEVILLE";
    else if code_bureau="6912" then nom_bureau="GIVORS";
    else if code_bureau="6914" then nom_bureau="L'ARBRESLE";
    else if code_bureau="6915" then nom_bureau="COURS LA VILLE";
    else if code_bureau="6917" then nom_bureau="LYON GERLAND";
    else if code_bureau="6918" then nom_bureau="LYON SAXE";
    else if code_bureau="6919" then nom_bureau="MEYZIEU";
     
    RUN;

  8. #8
    Membre émérite

    Homme Profil pro
    Consultant en Business Intelligence
    Inscrit en
    Mars 2005
    Messages
    1 364
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

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

    Informations forums :
    Inscription : Mars 2005
    Messages : 1 364
    Points : 2 329
    Points
    2 329
    Par défaut
    J'ai créé des varaleurs, le programme fonctionne bien, le problème peut avoir un lien avec ta table
    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
     
    data fichier_global;
    input code_bureau $4.;
    cards;
    0101
    2602
    3806
    3807
    3814
    ;
    run;
    DATA fichier_global;
    SET fichier_global;
    attrib nom_bureau format=$40.;
    IF code_bureau="0101" then nom_bureau="BOURG EN BRESSE";
    else IF code_bureau="0102" then nom_bureau="OYONNAX";
    else IF code_bureau="0103" then nom_bureau="BELLEY";
    else IF code_bureau="0104" then nom_bureau="MONTLUEL";
    else IF code_bureau="0105" then nom_bureau="AMBERIEU";
    else IF code_bureau="0501" then nom_bureau="GAP";
    else IF code_bureau="0503" then nom_bureau="BRIANCON";
    else IF code_bureau="0701" then nom_bureau="ANNONAY";
    else IF code_bureau="0702" then nom_bureau="TOURNON";
    else IF code_bureau="0704" then nom_bureau="AUBENAS";
    else IF code_bureau="2601" then nom_bureau="VALENCE";
    else IF code_bureau="2602" then nom_bureau="ROMANS SUR ISERE";
    else IF code_bureau="2603" then nom_bureau="MONTELIMAR";
    else IF code_bureau="2604" then nom_bureau="VALENCE CENTRE";
    else IF code_bureau="3801" then nom_bureau="VIENNE";
    else IF code_bureau="3802" then nom_bureau="MEYLAN";
    else IF code_bureau="3803" then nom_bureau="ECHIROLLES";
    else IF code_bureau="3804" then nom_bureau="VOIRON";
    else IF code_bureau="3805" then nom_bureau="BOURGOIN JALLIEU";
    else IF code_bureau="3806" then nom_bureau="SASSENAGE";
    else IF code_bureau="3807" then nom_bureau="PEAGE DE ROUSSILLON";
    else IF code_bureau="3808" then nom_bureau="PONTCHARRA";
    else IF code_bureau="3809" then nom_bureau="ST MARCELLIN";
    else IF code_bureau="3810" then nom_bureau="ST EGREVE";
    else IF code_bureau="3811" then nom_bureau="VIZILLE";
    else IF code_bureau="3812" then nom_bureau="LA TOUR DU PIN";
    else IF code_bureau="3813" then nom_bureau="GRENOBLE";
    else IF code_bureau="3814" then nom_bureau="GRENOBLE GAMBETTA";
    else IF code_bureau="4201" then nom_bureau="ST ETIENNE BELLEVUE";
    else IF code_bureau="4202" then nom_bureau="ROANNE";
    else IF code_bureau="4203" then nom_bureau="ANDREZIEUX BOUTHEON";
    else IF code_bureau="4204" then nom_bureau="ST ETIENNE BERGSON";
    else IF code_bureau="4205" then nom_bureau="ST CHAMOND";
    else IF code_bureau="4206" then nom_bureau="RIVE DE GIER";
    else IF code_bureau="4207" then nom_bureau="FIRMINY";
    else IF code_bureau="4209" then nom_bureau="MONTBRISON";
    else IF code_bureau="4210" then nom_bureau="CHARLIEU";
    else IF code_bureau="4211" then nom_bureau="FEURS";
    else IF code_bureau="4301" then nom_bureau="LE PUY";
    else IF code_bureau="4302" then nom_bureau="BRIOUDE";
    else IF code_bureau="6901" then nom_bureau="CHAMPAGNE AU MT D'OR";
    else IF code_bureau="6902" then nom_bureau="ST BONNET DE MURE";
    else IF code_bureau="6903" then nom_bureau="LYON GAMBETTA";
    else IF code_bureau="6904" then nom_bureau="VENISSIEUX";
    else IF code_bureau="6905" then nom_bureau="VILLEURBANNE";
    else IF code_bureau="6906" then nom_bureau="BRON";
    else IF code_bureau="6907" then nom_bureau="OULLINS";
    else IF code_bureau="6909" then nom_bureau="CALUIRE ET CUIRE";
    else IF code_bureau="6910" then nom_bureau="VILLEFRANCHE";
    else IF code_bureau="6911" then nom_bureau="FRANCHEVILLE";
    else IF code_bureau="6912" then nom_bureau="GIVORS";
    else IF code_bureau="6914" then nom_bureau="L'ARBRESLE";
    else IF code_bureau="6915" then nom_bureau="COURS LA VILLE";
    else IF code_bureau="6917" then nom_bureau="LYON GERLAND";
    else IF code_bureau="6918" then nom_bureau="LYON SAXE";
    else IF code_bureau="6919" then nom_bureau="MEYZIEU";
     
    RUN;
    Consultez les FAQs et les anciens postes avant de poser vos questions. Merci

  9. #9
    Membre actif

    Profil pro
    Inscrit en
    Avril 2008
    Messages
    233
    Détails du profil
    Informations personnelles :
    Âge : 48
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 233
    Points : 254
    Points
    254
    Par défaut
    Citation Envoyé par bahraoui Voir le message
    J'ai créé des varaleurs, le programme fonctionne bien, le problème peut avoir un lien avec ta table
    Tu as raison. En plus on voit très bien d'où vient la longueur du "grenoble gambet" - c'est la longueur de "BOURG EN BRESSE". Si on enlève la ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    attrib nom_bureau format=$40.;
    de ton code, c'est coupé comme dans l'exemple initial. Et si on remplace le premier IF par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    IF code_bureau="0101" then nom_bureau="BOURG EN BRESS";
    ce sera coupé à "grenoble gambe".

  10. #10
    Membre régulier
    Inscrit en
    Mai 2007
    Messages
    158
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 158
    Points : 71
    Points
    71
    Par défaut
    En fait la solution au problème est d'ajouter dans le programme :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    attrib nom_bureau length =$30;
    L'erreur que je faisais était de mettre un point après le $30.

    Merci quand même de votre aide
    Bonne soirée

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

Discussions similaires

  1. Proc tabulate et format : tri des variables
    Par Najua dans le forum SAS Base
    Réponses: 8
    Dernier message: 22/09/2010, 17h15
  2. Syntaxe pour des variables nommées
    Par uraharasama dans le forum ActionScript 3
    Réponses: 0
    Dernier message: 28/06/2010, 19h18
  3. Opérations simple pour des variables
    Par anayathefirst dans le forum Jasper
    Réponses: 8
    Dernier message: 31/03/2008, 11h57
  4. Problème de format pour des chiffres à virgule
    Par bob75000 dans le forum Access
    Réponses: 5
    Dernier message: 21/07/2006, 10h42
  5. Réponses: 3
    Dernier message: 19/12/2005, 13h39

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