Précédent   Forum des professionnels en informatique > Logiciels > Solutions d'entreprise > Business Intelligence > SAS > SAS Base
SAS Base Forum d'entraide sur SAS base : étape data, procédures non statistiques, procédures non graphiques, SQL
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 20/06/2008, 09h22   #1
Membre habitué
 
Avatar de pierre24
 
Inscription : février 2008
Messages : 269
Détails du profil
Informations personnelles :
Âge : 26
Localisation : France, Gironde (Aquitaine)

Informations forums :
Inscription : février 2008
Messages : 269
Points : 106
Points : 106
Envoyer un message via MSN à pierre24
Par défaut Syntaxe du WHEN

Bonjour,

je voudrais savoir comment fonctionne la boucle WHEN

Code :
1
2
3
4
5
6
 
WHEN ("var1") DO;
instruct1
instruct2
...
END;
__________________
Pierre24.
http://www.goguel-blog.com
Les racistes sont des gens qui se trompent de colère.
Léopold Sédar Senghor
pierre24 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/06/2008, 09h35   #2
Membre Expert
 
Inscription : mars 2005
Messages : 1 028
Détails du profil
Informations forums :
Inscription : mars 2005
Messages : 1 028
Points : 1 278
Points : 1 278
Envoyer un message via Yahoo à bahraoui
when c'est l'équivalent du IF.
c'est bien expliqué avec des exemple dans le help SAS.
Exemple,
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
 
DATA t;
a=1;x=1;output;a=2;x=1;output; a=3;x=1;output;a=4;x=1;output;
a=10;x=1;output;
run;
DATA t1; SET t;
SELECT (a);
   when (1) x=x*10;
   when (2);
   when (3,4,5) x=x*100;
   otherwise;
end;
run;
bahraoui est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/06/2008, 11h28   #3
Membre habitué
 
Avatar de pierre24
 
Inscription : février 2008
Messages : 269
Détails du profil
Informations personnelles :
Âge : 26
Localisation : France, Gironde (Aquitaine)

Informations forums :
Inscription : février 2008
Messages : 269
Points : 106
Points : 106
Envoyer un message via MSN à pierre24
Merci beaucoup bahraoui !!!
__________________
Pierre24.
http://www.goguel-blog.com
Les racistes sont des gens qui se trompent de colère.
Léopold Sédar Senghor
pierre24 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/06/2008, 13h10   #4
Membre habitué
 
Avatar de pierre24
 
Inscription : février 2008
Messages : 269
Détails du profil
Informations personnelles :
Âge : 26
Localisation : France, Gironde (Aquitaine)

Informations forums :
Inscription : février 2008
Messages : 269
Points : 106
Points : 106
Envoyer un message via MSN à pierre24
J'ai un probleme, je vous affiche ma LOG en espérant que vous pourrez m'aider

Code :
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
93
94
95
96
97
98
99
 
 
 DATA GP.SALARIES (keep=idgrc)                         /*110308
 
 
 GRCH.IDE (KEEP=                                               
 IDGRC SYSTGEST IDPART ETATBO ETAFFECT INSGFR INSCINT          
 COMPRESS=YES)                                                 
 
 ;                                                             
 /**************LENGTH DES TABLES**************/               
 
 /*******LENGTH DE LA TABLE IDGRC SALARIES**/       /*110308*/ 
 LENGTH IDGRC $ 15                                     /*110308
 
 ;                                                  /*110308*/ 
 
 /*******LENGTH DE LA TABLE IDENTIFIANTS PARTENAIRES*******/   
 LENGTH IDGRC $ 15 SYSTGEST $ 5 IDPART $ 15 ETATBO $ 30        
 ETAFFECT $ 30 INSCINT $ 1                                     
 ;                                                             
 
/**************VARIABLES DES TABLES**************/            
/*******VARIABLES DE LA TABLE IDENTIFIANTS PARTENAIRES*******/
 
SELECT (FLUX);                                                
WHEN ("IDE") DO;                                              
INPUT                                                         
FLUX     $                                                    
ORG       $                                                   
IDGRC     $                                                   
SYSTGEST  $                                                   
IDPART    $                                                   
ETATBO    $                                                   
ETAFFECT  $                                                   
                                                The SAS System
 
 
DINSGFR    $                                                  
INSCINT   $                                                   
;                                                             
/******* Retraitement d'une date **********/                  
INSGFR  = input (dinsgfr,yymmdd8.); Format INSGFR ddmmyy10.;  
;                                                             
LABEL                                                         
IDGRC     = "IDENTIIANT GRC"                                  
SYSTGEST  = "SYSTEME GESTION"                                 
IDPART    = "IDENTIFIANT PARTENAIRE"                          
     ETATBO    = "ETAT MIS A JOUR BO"                              
     ETAFFECT  = "ETAT MIS A JOUR AFFACTATION"                     
     DINSGFR   = "INSCRIT GFR LE"                                  
     INSCINT   = "INSCRIPTION INTERDITE"                           
     ;                                                             
     OUTPUT GRCH.IDE;                                              
     END;                                                          
     RUN;                                                          
 
     RUN;                                                          
        _                                                          
        _                                                          
        _                                                          
        117                                                        
        117                                                        
        117                                                        
117-185: There were 1 unclosed SELECT blocks.                      
117-185: There were 1 unclosed SELECT blocks.                      
117-185: There were 1 unclosed SELECT blocks.                      
 
Character VALUES have been converted TO numeric VALUES at the place
 
35:7                                                               
The SAS System stopped processing this step because of errors.     
SAS SET OPTION OBS=0 AND will continue TO CHECK statements. This ma
 
G: The DATA SET GP.SALARIES may be incomplete.  When this step was 
 
G: DATA SET GP.SALARIES was NOT replaced because this step was stop
 
G: The DATA SET GRCH.IDE may be incomplete.  When this step was sto
 
 
     options ERRORS=20;                                            
 
     proc sort DATA=GP.SALARIES;                                   
     BY IDGRC;                                                     
     run;                                                          
 
 
 
     proc sql;                                                     
               CREATE INDEX IDGRC ON GRCH.IDE (idgrc);             
Simple INDEX IDGRC has been defined.                               
                                                      quit;        
 
 Errors printed ON page 2.                                         
 Errors printed ON page 2.                                         
 Errors printed ON page 2.                                         
 
SAS Institute S.A., Boite Postale 5, 77166 Gregy-Sur-Yerres
__________________
Pierre24.
http://www.goguel-blog.com
Les racistes sont des gens qui se trompent de colère.
Léopold Sédar Senghor
pierre24 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/06/2008, 13h18   #5
Membre Expert
 
Inscription : mars 2005
Messages : 1 028
Détails du profil
Informations forums :
Inscription : mars 2005
Messages : 1 028
Points : 1 278
Points : 1 278
Envoyer un message via Yahoo à bahraoui
je vois dans la log un seul "end" qui doit correspondre au "DO"
Il manque le "end" du "select"
bahraoui est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/06/2008, 13h40   #6
Membre habitué
 
Avatar de pierre24
 
Inscription : février 2008
Messages : 269
Détails du profil
Informations personnelles :
Âge : 26
Localisation : France, Gironde (Aquitaine)

Informations forums :
Inscription : février 2008
Messages : 269
Points : 106
Points : 106
Envoyer un message via MSN à pierre24
en fait c'est pas moi qui est écrit le programme...

Je vais donc rajouter le END pour fermer le DO entre le END existant et le RUN;

Par contre une question : le DO est-il vraiment nécessaire apres le WHEN ?
__________________
Pierre24.
http://www.goguel-blog.com
Les racistes sont des gens qui se trompent de colère.
Léopold Sédar Senghor
pierre24 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/06/2008, 15h02   #7
Membre Expert
 
Inscription : mars 2005
Messages : 1 028
Détails du profil
Informations forums :
Inscription : mars 2005
Messages : 1 028
Points : 1 278
Points : 1 278
Envoyer un message via Yahoo à bahraoui
test, normalement chaque bloque de code est encadre par un do end, (debut fin)
bahraoui est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/06/2008, 11h51   #8
Membre Expert
 
Inscription : mars 2005
Messages : 1 028
Détails du profil
Informations forums :
Inscription : mars 2005
Messages : 1 028
Points : 1 278
Points : 1 278
Envoyer un message via Yahoo à bahraoui
pour moi c'est une question de lisibilité (indentation)du code.
Le when est plus sympas.
__________________
Consultez les FAQs et les anciens postes avant de poser vos questions. Merci
bahraoui est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 02h48.


 
 
 
 
Partenaires

Hébergement Web