Précédent   Forum des professionnels en informatique > Logiciels > Solutions d'entreprise > Business Intelligence > SAS > Macro
Macro Forum d'entraide sur le langage Macro de SAS
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 24/05/2011, 16h11   #1
Membre à l'essai
 
Inscription : novembre 2009
Messages : 107
Détails du profil
Informations forums :
Inscription : novembre 2009
Messages : 107
Points : 20
Points : 20
Par défaut Erreur dans macroprogramme

Bonjour ,
j ai fait un programme en utilisant une macro et j ai une erreur signalé par la macro et je n arrive pas a la corrigée.

Mon code

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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
%macro mypath ;
    %global  path dir pgm pname;
    %IF  %sysfunc(getoption(DMS))=DMS %then %do;    /*INTERACTIVE MODE*/
        %let pgm=%sysget(SAS_EXECFILENAME);
        %let path=%sysget(SAS_EXECFILEPATH);
    %end;
    %else %do;  /*BATCH MODE*/
        %let path= %sysfunc(getoption(sysin));
        %let pgm= %scan(&path, -1,"\");
    %end;
   %let dir = %substr(&path,1,%eval(%length(&path) - 
                       %length(%scan(&path,-2,"\")) - %length(%scan(&path,-1,"\")) - 2));
    *For recording the log;
    %let pname=%scan(&pgm,1,".");
    * check macro variables;
    *%put &dir &pgm &pname;
%mend;
%mypath;
 
*-------------------------------------------------------------------------------------------------------------------*;
 
%GLOBAL STUDY OUTFMT PAPERFMT ORIENTATION OUTDIR; 
 
%LET STUDY=FID31;
%LET OUTFMT=PDF9;
%LET PAPERFMT=LETTER;
%LET ORIENTATION=LAND;
%LET OUTDIR=&dir\OUTPUTS\; 
 
LIBNAME DB "Z:\DATASETS";
LIBNAME QC "Z:\QC\datasets";
LIBNAME format "Z:\FORMATS";
options fmtsearch=(format);
 
%inc "Z:\PROGRAMS\macros.sas" ; 
 
*-------------------------------------------------------------------------------------------------------------------*;
 
                                        /******************/
                                        /**   DATA SET   **/
                                        /******************/
 
DATA ADSL;
	SET DB.ADSL(WHERE = (TRTP ne ""));
RUN;  
 
 
/* Birth date */
DATA AGE; 
	SET DB.DM;
	KEEP USUBJID BRTHDTC;
RUN;
 
/* Decision made by */
 
DATA WHO_T;
SET DB.Suppds (KEEP=USUBJID QNAM QVAL WHERE = (INDEX(QNAM,"DSDEC")));
RUN;
 
DATA WHO_T;
attrib USUBJID LABEL="USUBJID";/* changer le label de USUBJID*/
attrib QVAL LABEL="DSDECWHO";/* ou LABEL="DATA value"*/
 
SET WHO_T;
drop QNAM/*supprimer QNAM*/;
RUN;
 
/* No / at least one missing sero results */
DATA ADIM1(KEEP= USUBJID VISITNUM);
SET DB.ADIM;
WHERE LBSTRES1 IN ("<10") ;
RUN;
 
PROC SORT DATA=ADIM1 NODUPKEYS; 
	BY USUBJID VISITNUM;
run;
DATA ADIM2(KEEP= USUBJID VISITNUM);
SET DB.ADIM;
WHERE LBSTRES1 IN ("NR") ;
RUN;
 
PROC SORT DATA=ADIM2 NODUPKEYS; 
	BY USUBJID VISITNUM;
run;
 
/* At least one result */
DATA ATONERES;
	SET ADIM1;
	ALLMISS="N";
RUN;
 
PROC TRANSPOSE DATA=ATONERES OUT=ATONERES_T(KEEP = USUBJID ALLMISS:) PREFIX=ALLMISS;
	VAR ALLMISS;
	ID VISITNUM;
	BY USUBJID;
RUN;
 
	/* At least one missing */
DATA ATONEMISS;
	SET ADIM2;
	ONEMISS="Y";
RUN;
 
PROC TRANSPOSE DATA=ATONEMISS OUT=ATONEMISS_T(KEEP = USUBJID ONEMISS:) PREFIX=ONEMISS;
	VAR ONEMISS;
	ID VISITNUM;
	BY USUBJID;
RUN;
 
/* Safety results */
 
PROC SORT DATA=DB.ADSR OUT=ADSR1(KEEP= USUBJID VISITNUM) NODUPKEYS;
	BY USUBJID VISITNUM;
RUN;
 
PROC SORT DATA=DB.ADAE OUT=ADAE1(KEEP= USUBJID VISITNUM) NODUPKEYS;
	BY USUBJID VISITNUM;
RUN;
 
	/* At least one sol */
DATA ATONESOL;
	SET ADSR1;
	SRMISS="N";
RUN;
 
PROC TRANSPOSE DATA=ATONESOL OUT=ATONESOL_T(KEEP = USUBJID SRMISS:) PREFIX=SRMISS;
	VAR SRMISS;
	ID VISITNUM;
	BY USUBJID;
RUN;
 
	/* At least one unsol */
DATA ATONEUNSOL;
	SET ADAE1;
	AEMISS="N";
RUN;
 
PROC TRANSPOSE DATA=ATONEUNSOL OUT=ATONEUNSOL_T(KEEP = USUBJID AEMISS:) PREFIX=AEMISS;
	VAR AEMISS;
	ID VISITNUM;
	BY USUBJID;
RUN;
 
 
/* gather all */
DATA DATA(DROP = AEMISS:);
	MERGE ADSL(IN=A) AGE WHO_T ATONERES_T ATONEMISS_T ATONESOL_T ATONEUNSOL_T;
	BY USUBJID;
	IF A;
 
	/* SERO */
	IF LBYNA1 ne "" AND ALLMISS1 ne "N" THEN  ALLMISS1 = "Y";
	IF LBYNA2 ne "" AND ALLMISS2 ne "N" THEN  ALLMISS2 = "Y";
	IF LBYNA1 ne "" AND ONEMISS1 ne "Y" THEN  ONEMISS1 = "N";
	IF LBYNA2 ne "" AND ONEMISS2 ne "Y" THEN  ONEMISS2 = "N";
 
 
	/* SAFETY */
	IF RFENDTC ne "" AND SRMISS2 ne "N" THEN  SRMISS2 = "Y";
	IF RFENDTC ne "" AND SRMISS2 ne "N" AND AEMISS2 ne "N" AND AEMISS99 ne "Y" THEN  SAFMISS2 = "N"; ELSE IF RFENDTC ne "" THEN SAFMISS2 = "N"; 
 
RUN;
 
/* (N=###) */
PROC SQL NOPRINT;
	SELECT COUNT(DISTINCT USUBJID) INTO :ntot1-:ntot2
	FROM ADSL
	GROUP BY TRTPN;
QUIT;
 
 
 
/******************/
/**    STATS     **/
/******************/
 
 
%MACRO BOUCLE();
 
 
 
      %DO AGE=0 %TO 3;
 
            DATA _DATA;
                  FORMAT labrow $100.;
                  SET DATA %IF &AGE ne 0 %THEN %DO; (WHERE = (AGEGRPN=&AGE)) %END;;
                  %OUTPUTS(2, "N randomized", (ARM ne ''),  );
                  %OUTPUTS(3, "N discontinued", (DSDECOD ne 'COMPLETED',  );
                  %OUTPUTS(4, "Serious adverse event", (DSDECOD='SERIOUS ADVERSE EVENT', 6 );
                  %OUTPUTS(5, "Other adverse event", (DSDECOD='ADVERSE EVENT'), 6 );
                  %OUTPUTS(6, "Non compliance WITH the protocol", (DSDECOD='PROTOCOL VIOLATION'), 6 );
                  %OUTPUTS(7, "Lost TO follow-up", (DSDECOD='LOST TO FOLLOW-UP'), 6 );
                  %OUTPUTS(8, "Voluntary withdrawal NOT due TO an AE  ", (DSDECOD='WITHDRAWAL BY SUBJECT'), 6 );
                  %OUTPUTS(10, "Investigator", ((DSDECOD ne 'COMPLETED' AND DSDEC="INV")), 6 );
                  %OUTPUTS(11, "Legal representative", ((DSDECOD ne 'COMPLETED' AND DSDEC="SUB")), 6 );
                  %OUTPUTS(12, "N WITH any visit missed", (RFENDTC='');
                  %OUTPUTS(15, "N WITH any vaccination missed", (TRTAN1=. ),  );
                  RUN;
 
            %n_et_pourc(fichiere=_DATA,fichiers=_OUT1,Groupe=TRTPN,decimales=1, _All=Y) ;
 
 
 
            /* Blood samples */
            DATA _DATA1;
                  FORMAT labrow $100.;
                  SET DATA;
 
           %IF &AGE. ne 0 %THEN 
            %DO; 
                  AGEGRPN=&AGE. ;
            %END;
                  %OUTPUTS(13, "N WITH any blood sample missed*", (( AND (LBYNA1='' OR LBYNA2='')) , );
                  %OUTPUTS(14, "N WITH at least one serology result missing*", 
                         AND (ONEMISS1="Y" OR ONEMISS2="Y" , );
            RUN;
 
 
 
      %END;
 
 
 
%MEND;
 
%BOUCLE();
 
DATA OUTPUT;
 
      SET OUTPUT_0 OUTPUT_1 OUTPUT_2 OUTPUT_3;
 
RUN;
 
 
/******************/
/** REPORTING    **/
/******************/
 
/* Headfoot */
DATA Headfoot;
	objno="TABLE.13";
	objlabel="FID31 - Summary of Subjects Adherence TO Trial Schedule across the Study - ALL Randomized Subjects";
	tableno="&pname";
	tableid="&pname";
	pgmid="&pname";
	ft1="Percentages are calculated among randomized subjects";
	ft2="* among subjects randomized FOR blood sample";
RUN;
 
/* SAS2OUTPUTS */
%BREAKP(OUTPUT,15);
%SAS2OUTPUTS(   _macro=REPORT(  DATASET=OUTPUT,
                                COL1=breakp,
                                COL2=age|"Age strata"|LEFT|BOLD|2.3,
                                COL3=labrow|"&_indent1"|LEFT|BOLD|6.5,
                                COL4=n1|"n/M"|CENTER|1.5,
                                COL5=p1|"%"|CENTER|1.5,
                                COL6=n2|"n/M"|CENTER|1.5,
                                COL7=p2|"%"|CENTER|1.5,
                                COL8=nz|"n/M"|CENTER|1.5,
                                COL9=pz|"%"|CENTER|1.5,
                                SPAN=4-5='FID@(N=&ntot1)'|6-7='Control Group@(N=&ntot2)'|8-9="ALL",
								OUT=QC.&pname),
            _Study="&study",
            _Pgmname="&pgm",
            _AFile="",
            _AOrient="LAND",
            _APaper="&PaperFmt",
            _AOutput="&OutFmt",
            _AObjTp="TABLE",
            _HdFtdata="Headfoot",
            _OutId="&pname",
            _AObjL=""
        );
 
/*************/
/** TERM **/
/*************/
/* Deletion of temporary datasets * recording of log */
%RECORDLOG;


la parti de macro qui me semble signaler l erreur
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
*************************/
/* PARAMETERS VALIDATION */
/*************************/
 
/*Checking for each parameter then for each element*/
%macro CHECK;
	/* Boolean information: Ok */
	%let error=0;		/*To validate that there is no error*/
	%let OrderCol=0;	/*To validate that the "Col=" parameters are filled in the good order*/
	%let ValidSS=0; 	/*To validate that each column in "Span=" parameter is single*/
	%let ValidEE=0; 	/*To validate that there is no empty element in a "Col=" parameter*/
 
	/* Other information */
	%let NbBrk=0; 		/*Nb de Break: Valid Single Break*/
	%let NbCol=1;		/*Number of columns: minimum 1*/
	%let DSVCols=;		/*All dataset variables in "Col=" parameters*/
	%let DSVLines=;		/*All dataset variables in "Lines=" parameters*/
	%let ColSpan=;		/*All N° of columns in "Span=" parameter*/
	%let LocNTar=; 		/*Locations And Targets for Compute Statement with Line Statement*/
 
	/*Minimal parameter setting*/
		/*"dataset=" parameter*/
		%CheckElt(elt=%QCMPRES(&dataset.),param=dataset);
		/*"Col=" parameters*/
		%do j=2 %TO 40;
			%let i=%eval(&j.-1);
			%IF %bquote(&&col&j.) ne  AND %bquote(&&col&i.)= %then %let OrderCol=1;
			%IF %bquote(&&col&j.) ne %then %let NbCol=&j.;
		%end;
		%IF &OrderCol=1 %then %do;
			%put === ERROR-MACRO REPORT: The "Col=" parameters must be filled IN the good ORDER ===;
			%let error=1;
		%end;
		%else %IF %bquote(&col1.)= %then %do;
			%put === ERROR-MACRO REPORT: "Col1=" parameter can NOT be empty ===;
			%let error=1;
		%end;
 
	/*Others parameters*/
	%IF &error.=0 %then %do;
		proc contents DATA=&dataset. out=VarNames noprint;run;
 
		DATA _null_;
			SET VarNames (keep=name);
			call symput('var'||LEFT(put(_N_,8.)),compress(name));
			call symput('Nbvar',put(_N_,8.));
		run;
 
		/*"report=" parameter*/
		%let i=1;
		%do %while (%qscan(&report.,&i.,|) ne );
			%let elt=%QCMPRES(%qscan(%BQUOTE(&report.),&i.,|));
			%CheckElt(elt=&elt.,param=report);
			%let i=%eval(&i.+1);
		%end;
		/*It may stop the loop prematurely: some elements would not be checked*/
		%IF %INDEX(%qsysfunc(compress("&report.")),||) ne 0 %then %do;
			%put === ERROR-MACRO REPORT: There IS an empty element (|empty|) IN "Report=" parameter ===;
			%let error=1;
		%end;
 
		/*"col=" parameters*/
		%do j=1 %TO 40;
			%let i=1;
			%let ValidDSV=0; /* To validate that there is a single DataSet-Variable in each "Col=" parameter */
			%let ValidBrk=0; /* Boolean information: Presence Break element */
			%do %while (%qscan(&&col&j.,&i.,|) ne );
				%let elt=%QCMPRES(%qscan(%BQUOTE(&&col&j.),&i.,|));
				%CheckElt(elt=&elt.,param=col&j);
				%let i=%eval(&i.+1);
			%end;
			%IF &validDSV>1 %then %do;
				%put === ERROR-MACRO REPORT: Only one dataset variable must be specified IN "col&j=" parameter ===;
				%let error=1;
			%end;
			%IF %INDEX(%qsysfunc(compress("%BQUOTE(&&col&j.)")),||)=0 %then %do;
				/*Inside the condition to not write a false error message*/
				%IF %BQUOTE(&&col&j.) ne AND &validDSV=0 %then %do;
					%put === ERROR-MACRO REPORT: A dataset variable must be specified IN "col&j=" parameter ===;
					%let error=1;
				%end;
			%end;
			/*It may stop the loop prematurely: some elements would not be checked*/
			%else %do;
				%put === ERROR-MACRO REPORT: There IS an empty element (|empty|) IN "Col&j.=" parameter ===;
				%let error=1;
				%let ValidEE=1;
			%end;
			%let NbBrk=%eval(&NbBrk.+&ValidBrk.);/*Computed on the 40 parameters*/
		%end;
		%IF &NbBrk>1 %then %do;
			%put === ERROR-MACRO REPORT: Only one break variable can be specified ===;
			%let error=1;
		%end;
 
		/*"span=" parameter*/
		%let i=1;
		%do %while (%qscan(&span.,&i.,|) ne );
			%let elt=%QCMPRES(%qscan(%BQUOTE(&span.),&i.,|));
			%CheckElt(elt=&elt.,param=span);
			%let i=%eval(&i.+1);
		%end;
		/*Validation: Intervals in "Span=" parameter are coherent*/
		%IF &ColSpan. ne %then %do;
			/*If a column to span is not defined*/
			%IF %sysfunc(max(0,&ColSpan))>&NbCol. %then %do;
				%put === ERROR-MACRO REPORT: The COLUMNS TO span must be specified IN a "Col=" parameter ===;
				%let error=1;
			%end;
		%end;
		/*If a column is spanned twice*/
		%let i=1;
		%let ColSpan=%bquote(%str(, )&ColSpan.%str(,));
		%do %while (%qscan(&ColSpan.,&i.,%str(,)) ne );
			%IF %length(%qsysfunc(tranwrd(&ColSpan.,%qscan(&ColSpan.,&i.,%str(,))%str(,),))) ne %eval(%length(&ColSpan.)-%length(%qscan(&ColSpan.,&i.,%str(,)))) %then %let ValidSS=1;
			%let i=%eval(&i.+1);
		%end;
		%IF &ValidSS.=1 %then %do;
			%put === ERROR-MACRO REPORT: Each COLUMN can be specified only once IN "Span" parameter  ===;
			%let error=1;
		%end;
		/*It may stop the loop prematurely: some elements would not be checked*/
		%IF %INDEX(%qsysfunc(compress("&span.")),||) ne 0 %then %do;
			%put === ERROR-MACRO REPORT: There IS an empty element (|empty|) IN "Span=" parameter ===;
			%let error=1;
		%end;
 
		/*"lines=" parameters*/
		%do j=1 %TO 5;
			%let i=1;
			%let validLoc=0; /* Valid single Location & Target (DataSet Variable) in each "Lines=" parameter */
			%do %while (%qscan(&&lines&j.,&i.,|) ne );
				%let elt=%QCMPRES(%qscan(%BQUOTE(&&lines&j.),&i.,|));
				%CheckElt(elt=&elt.,param=lines&j);
				%let i=%eval(&i.+1);
			%end;
			%IF %BQUOTE(&&lines&j.) ne AND &validLoc>1 %then %do;
				%put === ERROR-MACRO REPORT: The location AND valid dataset variable TO associate WITH the compute block must be single IN "lines&j=" parameter ===;
				%let error=1;
			%end;
			%IF %INDEX(%qsysfunc(compress("&&lines&j.")),||)=0 %then %do;
				%IF %BQUOTE(&&lines&j.) ne AND &validLoc=0 %then %do;
					%put === ERROR-MACRO REPORT: A location AND a valid dataset variable TO associate WITH the compute block must be specified IN "Lines&j=" parameter ===;
					%let error=1;
				%end;
			%end;
			/*It may stop the loop prematurely: some elements would not be checked*/
			%else %do;
				%put === ERROR-MACRO REPORT: There IS an empty element (|empty|) IN "Lines&j.=" parameter ===;
				%let error=1;
			%end;
		%end;
 
		/*Coherence between "Col=" and "Lines=" parameters*/
		%IF &ValidEE.=0 %then %do;
			%let i=1;
			%do %while (%qscan(&DSVLines.,&i.,%STR ( )) ne );
				%IF %INDEX(&DSVCols.,%qscan(&DSVLines.,&i.,%STR ( )))=0 %then %do;
					%put === ERROR-MACRO REPORT: The dataset variable "%qscan(&DSVLines.,&i.,%STR ( ))" which appears IN a "Lines=" parameter must be specified IN a "Col=" parameter ===;
					%let error=1;
				%end;
				%let i=%eval(&i.+1);
			%end;
		%end;
 
		/*"WithS2O=" parameter*/
		%IF NOT(%qupcase(%qsysfunc(compress(&WithS2O.)))=Y OR %qupcase(%qsysfunc(compress(&WithS2O.)))=N) %then %do;
			%put === ERROR-MACRO REPORT: "WithS2O=" parameter can take only 2 VALUES: Y (WITH SAS2OUTPUTS) OR N (NOT WITH SAS2OUTPUTS) ===;
			%let error=1;
		%end;
	%end;
%mend CHECK;

La Log

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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
               ****************************************************;
3257                                *    Program Name     : MD12_FID31.SAS             *;
3258                                *    Scope            :   *;
3259                                *    Programmer Name  :                *;
3260                                *    Start Date       : 10 may 2011
3261                                                                                   *;
3262                                *    Evolution        : En cours                   *;
3263                                ****************************************************;
3264
3265
3266  %macro mypath ;
3267      %global  path dir pgm pname;
3268      %IF  %sysfunc(getoption(DMS))=DMS %then %do;    /*INTERACTIVE MODE*/
3269          %let pgm=%sysget(SAS_EXECFILENAME);
3270          %let path=%sysget(SAS_EXECFILEPATH);
3271      %end;
3272      %else %do;  /*BATCH MODE*/
3273          %let path= %sysfunc(getoption(sysin));
3274          %let pgm= %scan(&path, -1,"\");
3275      %end;
3276     %let dir = %substr(&path,1,%eval(%length(&path) -
3277                         %length(%scan(&path,-2,"\")) - %length(%scan(&path,-1,"\")) - 2));
3278      *For recording the log;
3279      %let pname=%scan(&pgm,1,".");
3280      * check macro variables;
3281      *%put &dir &pgm &pname;
3282  %mend;
3283  %mypath;
Z:\program\macros.sas
3284
3285  *-----------------------------------------------------------------------------------------
3285! --------------------------*;
3286
3287  %GLOBAL STUDY OUTFMT PAPERFMT ORIENTATION OUTDIR;
3288
3289  %LET STUDY=FID31;
3290  %LET OUTFMT=PDF9;
3291  %LET PAPERFMT=LETTER;
3292  %LET ORIENTATION=LAND;
3293  %LET OUTDIR=&dir\OUTPUTS\;
3294
3295  LIBNAME DB "Z:\DATASETS";
3296  LIBNAME QC "Z:\QC\datasets";
3297  LIBNAME format "Z:\FORMATS";
3298  options fmtsearch=(format);
3299
3300  %inc "Z:\PROGRAMS\macros.sas" ;
3301
3302  *-----------------------------------------------------------------------------------------
3302! --------------------------*;
3303
3304                                          /******************/
3305                                          /**   DATA SET   **/
3306                                          /******************/
3307
3308  DATA ADSL;
3309      SET DB.ADSL(WHERE = (TRTP ne ""));
3310  RUN;
3311
3312
3313  /* Birth date */
3314  DATA AGE;
3315      SET DB.DM;
3316      KEEP USUBJID BRTHDTC;
3317  RUN;
3318
3319  /* Decision made by */
3320
3321  DATA WHO_T;
3322  SET DB.Suppds (KEEP=USUBJID QNAM QVAL WHERE = (INDEX(QNAM,"DSDEC")));
3323  RUN;
3324
3325  DATA WHO_T;
3326  attrib USUBJID LABEL="USUBJID";/* changer le label de USUBJID*/
3327  attrib QVAL LABEL="DSDECWHO";/* ou LABEL="DATA value"*/
3328
3329  SET WHO_T;
3330  drop QNAM/*supprimer QNAM*/;
3331  RUN;
3332
3333  /* No / at least one missing sero results */
3334  DATA ADIM1(KEEP= USUBJID VISITNUM);
3335  SET DB.ADIM;
3336  WHERE LBSTRES1 IN ("<10") ;
3337  RUN;
3338
3339  PROC SORT DATA=ADIM1 NODUPKEYS;
3340      BY USUBJID VISITNUM;
3341  run;
3342  DATA ADIM2(KEEP= USUBJID VISITNUM);
3343  SET DB.ADIM;
3344  WHERE LBSTRES1 IN ("NR") ;
3345  RUN;
3346
3347  PROC SORT DATA=ADIM2 NODUPKEYS;
3348      BY USUBJID VISITNUM;
3349  run;
3350
3351  /* At least one result */
3352  DATA ATONERES;
3353      SET ADIM1;
3354      ALLMISS="N";
3355  RUN;
3356
3357  PROC TRANSPOSE DATA=ATONERES OUT=ATONERES_T(KEEP = USUBJID ALLMISS:) PREFIX=ALLMISS;
3358      VAR ALLMISS;
3359      ID VISITNUM;
3360      BY USUBJID;
3361  RUN;
3362
3363      /* At least one missing */
3364  DATA ATONEMISS;
3365      SET ADIM2;
3366      ONEMISS="Y";
3367  RUN;
3368
3369  PROC TRANSPOSE DATA=ATONEMISS OUT=ATONEMISS_T(KEEP = USUBJID ONEMISS:) PREFIX=ONEMISS;
3370      VAR ONEMISS;
3371      ID VISITNUM;
3372      BY USUBJID;
3373  RUN;
3374
3375  /* Safety results */
3376
3377  PROC SORT DATA=DB.ADSR OUT=ADSR1(KEEP= USUBJID VISITNUM) NODUPKEYS;
3378      BY USUBJID VISITNUM;
3379  RUN;
3380
3381  PROC SORT DATA=DB.ADAE OUT=ADAE1(KEEP= USUBJID VISITNUM) NODUPKEYS;
3382      BY USUBJID VISITNUM;
3383  RUN;
3384
3385      /* At least one sol */
3386  DATA ATONESOL;
3387      SET ADSR1;
3388      SRMISS="N";
3389  RUN;
3390
3391  PROC TRANSPOSE DATA=ATONESOL OUT=ATONESOL_T(KEEP = USUBJID SRMISS:) PREFIX=SRMISS;
3392      VAR SRMISS;
3393      ID VISITNUM;
3394      BY USUBJID;
3395  RUN;
3396
3397      /* At least one unsol */
3398  DATA ATONEUNSOL;
3399      SET ADAE1;
3400      AEMISS="N";
3401  RUN;
3402
3403  PROC TRANSPOSE DATA=ATONEUNSOL OUT=ATONEUNSOL_T(KEEP = USUBJID AEMISS:) PREFIX=AEMISS;
3404      VAR AEMISS;
3405      ID VISITNUM;
3406      BY USUBJID;
3407  RUN;
3408
3409
3410  /* gather all */
3411  DATA DATA(DROP = AEMISS:);
3412      MERGE ADSL(IN=A) AGE WHO_T ATONERES_T ATONEMISS_T ATONESOL_T ATONEUNSOL_T;
3413      BY USUBJID;
3414      IF A;
3415
3416      /* SERO */
3417      IF LBYNA1 ne "" AND ALLMISS1 ne "N" THEN  ALLMISS1 = "Y";
3418      IF LBYNA2 ne "" AND ALLMISS2 ne "N" THEN  ALLMISS2 = "Y";
3419      IF LBYNA1 ne "" AND ONEMISS1 ne "Y" THEN  ONEMISS1 = "N";
3420      IF LBYNA2 ne "" AND ONEMISS2 ne "Y" THEN  ONEMISS2 = "N";
3421
3422
3423      /* SAFETY */
3424      IF RFENDTC ne "" AND SRMISS2 ne "N" THEN  SRMISS2 = "Y";
3425      IF RFENDTC ne "" AND SRMISS2 ne "N" AND AEMISS2 ne "N" AND AEMISS99 ne "Y" THEN
3425! SAFMISS2 = "N"; ELSE IF RFENDTC ne "" THEN SAFMISS2 = "N";
3426
3427  RUN;
3428
3429  /* (N=###) */
3430  PROC SQL NOPRINT;
3431      SELECT COUNT(DISTINCT USUBJID) INTO :ntot1-:ntot2
3432      FROM ADSL
3433      GROUP BY TRTPN;
3434  QUIT;
3435
3436
3437
3438  /******************/
3439  /**    STATS     **/
3440  /******************/
3441
3442
3443  %MACRO BOUCLE();
3444
3445
3446
3447        %DO AGE=0 %TO 3;
3448
3449              DATA _DATA;
3450                    FORMAT labrow $100.;
3451                    SET DATA %IF &AGE ne 0 %THEN %DO; (WHERE = (AGEGRPN=&AGE)) %END;;
3452                    %OUTPUTS(2, "N randomized", (ARM ne ''),  );
3453                    %OUTPUTS(3, "N discontinued", (DSDECOD ne 'COMPLETED',  );
3454                    %OUTPUTS(4, "Serious adverse event", (DSDECOD='SERIOUS ADVERSE EVENT', 6
3454!  );
3455                    %OUTPUTS(5, "Other adverse event", (DSDECOD='ADVERSE EVENT'), 6 );
3456                    %OUTPUTS(6, "Non compliance WITH the protocol", (DSDECOD='PROTOCOL
3456! VIOLATION'), 6 );
3457                    %OUTPUTS(7, "Lost TO follow-up", (DSDECOD='LOST TO FOLLOW-UP'), 6 );
3458                    %OUTPUTS(8, "Voluntary withdrawal NOT due TO an AE  ",
3458! (DSDECOD='WITHDRAWAL BY SUBJECT'), 6 );
3459                    %OUTPUTS(10, "Investigator", ((DSDECOD ne 'COMPLETED' AND DSDEC="INV")),
3459!  6 );
3460                    %OUTPUTS(11, "Legal representative", ((DSDECOD ne 'COMPLETED' AND
3460! DSDEC="SUB")), 6 );
3461                    %OUTPUTS(12, "N WITH any visit missed", (RFENDTC='');
3462                    %OUTPUTS(15, "N WITH any vaccination missed", (TRTAN1=. ),  );
3463                    RUN;
3464
3465              %n_et_pourc(fichiere=_DATA,fichiers=_OUT1,Groupe=TRTPN,decimales=1, _All=Y) ;
3466
3467
3468
3469              /* Blood samples */
3470              DATA _DATA1;
3471                    FORMAT labrow $100.;
3472                    SET DATA;
3473
3474             %IF &AGE. ne 0 %THEN
3475              %DO;
3476                    AGEGRPN=&AGE. ;
3477              %END;
3478                    %OUTPUTS(13, "N WITH any blood sample missed*", (( AND (LBYNA1='' OR
3478! LBYNA2='')) , );
3479                    %OUTPUTS(14, "N WITH at least one serology result missing*",
3480                           AND (ONEMISS1="Y" OR ONEMISS2="Y" , );
3481              RUN;
3482
3483
3484
3485        %END;
3486
3487
3488
3489  %MEND;
3490
3491  %BOUCLE();
3492
3493  DATA OUTPUT;
3494
3495        SET OUTPUT_0 OUTPUT_1 OUTPUT_2 OUTPUT_3;
3496
3497  RUN;
3498
3499
3500  /******************/
3501  /** REPORTING    **/
3502  /******************/
3503
3504  /* Headfoot */
3505  DATA Headfoot;
3506      objno="TABLE.13";
3507      objlabel="FID31 - Summary of Subjects Adherence TO Trial Schedule across the Study -
3507! ALL Randomized Subjects";
3508      tableno="MD12_FID31";
3509      tableid="MD12_FID31";
3510      pgmid="MD12_FID31";
3511      ft1="Percentages are calculated among randomized subjects";
3512      ft2="* among subjects randomized FOR blood sample";
3513  RUN;
3514
3515  /* SAS2OUTPUTS */
3516  %BREAKP(OUTPUT,15);
3517  %SAS2OUTPUTS(   _macro=REPORT(  DATASET=OUTPUT,
3518                                  COL1=breakp,
3519                                  COL2=age|"Age strata"|LEFT|BOLD|2.3,
3520                                  COL3=labrow|"&_indent1"|LEFT|BOLD|6.5,
3521                                  COL4=n1|"n/M"|CENTER|1.5,
3522                                  COL5=p1|"%"|CENTER|1.5,
3523                                  COL6=n2|"n/M"|CENTER|1.5,
3524                                  COL7=p2|"%"|CENTER|1.5,
3525                                  COL8=nz|"n/M"|CENTER|1.5,
3526                                  COL9=pz|"%"|CENTER|1.5,
3527                                  SPAN=4-5='FID@(N=&ntot1)'|6-7='Control
3527! Group@(N=&ntot2)'|8-9="ALL",
3528                                  OUT=QC.&pname),
3529              _Study="&study",
3530              _Pgmname="MD12_FID31",
3531              _AFile="",
3532              _AOrient="LAND",
3533              _APaper="&PaperFmt",
3534              _AOutput="&OutFmt",
3535              _AObjTp="TABLE",
3536              _HdFtdata="Headfoot",
3537              _OutId="MD12_FID31",
3538              _AObjL=""
3539          );
PDF9
%put'=== ERROR: "MD12_FID31" is not referenced in Headfoot ==='
%put'=== ERROR-MACRO REPORT: "OUTPUT" is not a valid DataSet ==='[/COLOR]
3540
3541  /*************/
3542  /** TERM **/
3543  /*************/
3544  /* Deletion of temporary datasets * recording of log */
3545  %RECORDLOG;
asty69 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/05/2011, 16h25   #2
Modérateur
 
Homme Samir SELMANE
Consultant en Business Intelligence
Inscription : février 2011
Messages : 1 006
Détails du profil
Informations personnelles :
Nom : Homme Samir SELMANE
Localisation : France

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

Informations forums :
Inscription : février 2011
Messages : 1 006
Points : 1 703
Points : 1 703
ajoutes des quottes dans : %put '=== .......... ===';

exemple dans :

Code :
1
2
3
4
5
 
 
 
%put '=== ERROR-MACRO REPORT: The "Col=" parameters must be filled IN the good ORDER ===';
						%put === 'ERROR-MACRO REPORT: "Col1=" parameter can NOT be empty ===';
Ps: j'en ai pas encore regardé tout le programme.
s_a_m est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/05/2011, 16h29   #3
Membre à l'essai
 
Inscription : novembre 2009
Messages : 107
Détails du profil
Informations forums :
Inscription : novembre 2009
Messages : 107
Points : 20
Points : 20
je n ai pas le droit de toucher a la macro
mais j ai mis lesput dans l erreur dans la log
asty69 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/05/2011, 16h33   #4
Modérateur
 
Homme Samir SELMANE
Consultant en Business Intelligence
Inscription : février 2011
Messages : 1 006
Détails du profil
Informations personnelles :
Nom : Homme Samir SELMANE
Localisation : France

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

Informations forums :
Inscription : février 2011
Messages : 1 006
Points : 1 703
Points : 1 703
Désolé je n'ai pas compris; mais visiblement la macro telle qu'elle ne marchera pas et puis mettre les quottes te coûtera rien du tout.
s_a_m est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/05/2011, 16h35   #5
Membre à l'essai
 
Inscription : novembre 2009
Messages : 107
Détails du profil
Informations forums :
Inscription : novembre 2009
Messages : 107
Points : 20
Points : 20
Citation:
Envoyé par s_a_m Voir le message
Désolé je n'ai pas compris; mais visiblement la macro telle qu'elle ne marchera pas et puis mettre les quottes te coûtera rien du tout.
je vais mettre les cotes
asty69 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/05/2011, 16h51   #6
Modérateur
 
Homme Samir SELMANE
Consultant en Business Intelligence
Inscription : février 2011
Messages : 1 006
Détails du profil
Informations personnelles :
Nom : Homme Samir SELMANE
Localisation : France

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

Informations forums :
Inscription : février 2011
Messages : 1 006
Points : 1 703
Points : 1 703
Citation:
Envoyé par asty69 Voir le message
je vais mettre les cotes
ok! Sinon mets ce que tu veux ou bien replaces les (=) après %put par autre chose;

Code :
1
2
3
4
5
6
7
 
 
%put = pas correcte;
%pu rien = correcte; 
%put ' =  pas correcte;
 
%put ' =  correcte';
s_a_m est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/05/2011, 16h58   #7
Membre Expert
 
Homme
Biostatisticien
Inscription : juin 2009
Messages : 1 143
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Irlande

Informations professionnelles :
Activité : Biostatisticien
Secteur : Industrie Pharmaceutique

Informations forums :
Inscription : juin 2009
Messages : 1 143
Points : 1 760
Points : 1 760
wow c'est du lourd...

Pareil, je n'ai pas tout regardé... mais à ce que je vois de ta log, rien n'est éxécuté, et aucune erreur n'est mentionnée.

Où se situe le problème? Si tu ne sais pas exécute ton programme pas à pas.
Manoutz est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/05/2011, 17h01   #8
Membre Expert
 
Avatar de MEGAMIND2
 
Homme Brice Beare
Paris
Inscription : janvier 2011
Messages : 956
Détails du profil
Informations personnelles :
Nom : Homme Brice Beare
Localisation : France, Paris (Île de France)

Informations professionnelles :
Activité : Paris

Informations forums :
Inscription : janvier 2011
Messages : 956
Points : 1 366
Points : 1 366
Si j’ai bien compris tu as la macro sas2outputs (ci-dessous) qui prend en parametre une macro (en rouge) :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
%macro sas2outputs(_Macro="",/* Name of the macro without % */
				  _HdFtdata="",/* (Optionnal if _Aobjl="") Headfoot Dataset Name - reference to the metadata - Titles&footnotes */
                 _OutID="",   /* Output ID - reference in Headfoot dataset - Can be empty if _HdFtdata="" ) */
                 _RefData="", /* Datasets references - dataset(s) accessed in the program */
				 _study="",/* Study Code mandatory */
				 _Pgmname="",/* Programe name mandatory */
                 _AFile="C:\ -Test", /* File localisation+name (without extension) Eg:- "&outdir\T09001"  */
                 _AOrient="PORT",    /* Paper Orientation {PORT,LAND}                          */
                 _AOutput="PDF9",    /* Output format + size {RTF10,RTF9,RTF8,PDF10,PDF9,PDF8,LST8,LST6}  */
                 _APaper="LETTER",   /* Paper format {A4,LETTER}                               */
                 _AObjTp="TABLE",  /* Object type {TABLE,FIGURE,LISTING,NONE}                */
                 _AObjL="",          /* Object label (<=200 characters)                        */
                 /* Last page comments # (Optional, <= 200 characters) */
                 _ALC1=" " ,_ALC2=" " ,_ALC3=" " ,_ALC4=" " ,_ALC5=" " ,_ALC6=" " ,_ALC7=" " ,_ALC8=" " ,_ALC9=" " ,_ALC10=" ",
				
                 _ALC11=" " ,_ALC12=" " ,_ALC13=" " ,_ALC14=" " ,_ALC15=" " ,_ALC16=" " ,_ALC17=" " ,_ALC18=" " ,_ALC19=" " ,_ALC20=" "
             
               ) ;
Qui fait appel à une macro report, et cette macro s’attend a un nom autre que OUTPUT car c’est resevé

Code :
1
2
3
4
5
6
7
8
9
10
11
%macro report	(	dataset=, /*Input Dataset*/
					report=, /*General options of the report*/
					col1=,col2=,col3=,col4=,col5=,col6=,col7=,col8=,col9=,col10=, /*Options of layout of each column of the report*/
					col11=,col12=,col13=,col14=,col15=,col16=,col17=,col18=,col19=,col20=,
					col21=,col22=,col23=,col24=,col25=,col26=,col27=,col28=,col29=,col30=,
					col31=,col32=,col33=,col34=,col35=,col36=,col37=,col38=,col39=,col40=,
					span=, /*To span column(s) with headers*/
					lines1=,lines2=,lines3=,lines4=,lines5=, /*For writing customized summaries lines*/
					WithS2O=Y, /*With %SAS2OUTPUTS Macro (Y|N): Default=YES*/
					Out=, /* Output Dataset */
				);
La macro report est executé avec DATASET=OUTPUT

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
 %SAS2OUTPUTS(   _macro=REPORT(  DATASET=OUTPUT,
                                 COL1=breakp,
                                  COL2=age|"Age strata"|LEFT|BOLD|2.3,
                                  COL3=labrow|"&_indent1"|LEFT|BOLD|6.5,
                                  COL4=n1|"n/M"|CENTER|1.5,
                                 COL5=p1|"%"|CENTER|1.5,
                                  COL6=n2|"n/M"|CENTER|1.5,
                                  COL7=p2|"%"|CENTER|1.5,
                                  COL8=nz|"n/M"|CENTER|1.5,
                                  COL9=pz|"%"|CENTER|1.5,
                                  SPAN=4-5='FID@(N=&ntot1)'|6-7='Control
! Group@(N=&ntot2)'|8-9="ALL",
                                  OUT=QC.&pname),
             _Study="&study",
              _Pgmname="MD12_FID31",
              _AFile="",
             _AOrient="LAND",
              _APaper="&PaperFmt",
              _AOutput="&OutFmt",
              _AObjTp="TABLE",
              _HdFtdata="Headfoot",
             _OutId="MD12_FID31",
              _AObjL=""
         );
C’est pour ça dans la log tu as ce méssage :
Code :
1
2
 
ERROR-MACRO REPORT: "OUTPUT" IS NOT a valid DataSet
À toi de trouver donc la bonne table en paramètre

Bon courage!
MEGAMIND2 est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 25/05/2011, 10h51   #9
Membre à l'essai
 
Inscription : novembre 2009
Messages : 107
Détails du profil
Informations forums :
Inscription : novembre 2009
Messages : 107
Points : 20
Points : 20
ok je vois l'erreur ma macro output ne crée pas de data output
merci de votre aide
maintenant faut je trouve pourquoi je n ai pas de data
asty69 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 14h19.


 
 
 
 
Partenaires

Hébergement Web