Hello!
Can anyone tell me what is wrong with this code?
ods excel file = "/folders/myfolders/Research/Master List 07062020 SAS.xlsx"
%macro logitc(resp=,event=,class=,ref=,where=);
proc logistic data=import plots(only)=roc(id=prob);
where;
class &class(ref="&ref")/ param=ref;
model &resp(event="&event") = &class /link=logit outroc=roc cl /*firth*/ rsquare;
/*exact "&class" &class / estimate=parm;*/
/*output out=outstats p=pred ;*/
run;
%mend;
%logitc(resp=Preg_Group,event=Miscarriage,class=BMI_cat,ref=19<=BMI<23,where=BMI_cat ^= 'BMI Other '); /*0.*/
%logitc(resp=Preg_Group,event=Miscarriage,class=Age_cat,ref=Age <32) ); /*0.*/
%macro logitx(resp=,event=,x=,where=);
proc logistic data=import plots(only)=roc(id=prob);
where;
model &resp(event="&event") = &x /link=logit outroc=roc cl /*firth*/ rsquare rocci;
run;
%mend;
%logitx(resp=Preg_Group,event=Miscarriage,x=BMI); /*0.*/
%logitx(resp=Preg_Group,event=Miscarriage,x=Age); /*0.*/
title 'Mult Logistic Reg ';
proc logistic data=import plots(only)=roc(id=prob); where BMI_cat ^= 'BMI Other ';
class Age_cat(ref='Age <32')/param=ref;
model Preg_Group(event="Miscarriage") = BMI Age_cat Prog_1
/link=logit outroc=roc rsquare rocci cl/*nofit*/;
/*roc 'SIS ' SIS ;*/
/*roc 'Sex PoinSD2 Temp' Gender Poincare_plot_SD2__ms_ Temperature_Reading__1_ ;*/
/*roccontrast 'Compare'/estimate=allpairs;*/
run;
Log:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; NOTE: ODS statements in the SAS Studio environment may disable some output features. 73 74 ods excel file = "/folders/myfolders/Research/Master List 07062020 SAS.xlsx" 75 %macro logitc(resp=,event=,class=,ref=,where=); 76 proc logistic data=import plots(only)=roc(id=prob); 77 where; 78 class &class(ref="&ref")/ param=ref; 79 model &resp(event="&event") = &class /link=logit outroc=roc cl /*firth*/ rsquare; 80 /*exact "&class" &class / estimate=parm;*/ 81 /*output out=outstats p=pred ;*/ 82 run; 83 %mend; 84 85 %logitc(resp=Preg_Group,event=Miscarriage,class=BMI_cat,ref=19<=BMI<23,where=BMI_cat ^= 'BMI Other '); /*0.*/ NOTE: Line generated by the invoked macro "LOGITC". 85 proc logistic data=import plots(only)=roc(id=prob); where; class &class(ref="&ref")/ param=ref; model ____ ___ __ 22 22 22 202 202 202 85 ! &resp(event="&event") = &class /link=logit outroc=roc cl rsquare; run; NOTE: Line generated by the invoked macro "LOGITC". 85 proc logistic data=import plots(only)=roc(id=prob); where; class &class(ref="&ref")/ param=ref; model _____ 180 85 ! &resp(event="&event") = &class /link=logit outroc=roc cl rsquare; run; ERROR 22-322: Syntax error, expecting one of the following: ;, ANCHOR, AUTHOR, BOX_SIZING, CATEGORY, CLOSE, COMMENTS, CSSSTYLE, DOM, DPI, FILE, GFOOTNOTE, GTITLE, IMAGE_DPI, KEYWORDS, NOGFOOTNOTE, NOGTITLE, OPTIONS, SASDATE, STATUS, STYLE, TEXT, TITLE, WORK. ERROR 202-322: The option or parameter is not recognized and will be ignored. ERROR 180-322: Statement is not valid or it is used out of proper order. NOTE: Line generated by the invoked macro "LOGITC". 85 proc logistic data=import plots(only)=roc(id=prob); where; class &class(ref="&ref")/ param=ref; model _____ 180 85 ! &resp(event="&event") = &class /link=logit outroc=roc cl rsquare; run; ERROR 180-322: Statement is not valid or it is used out of proper order. NOTE: Line generated by the invoked macro "LOGITC". 85 proc logistic data=import plots(only)=roc(id=prob); where; class &class(ref="&ref")/ param=ref; model _____ 180 85 ! &resp(event="&event") = &class /link=logit outroc=roc cl rsquare; run; ERROR 180-322: Statement is not valid or it is used out of proper order. 86 %logitc(resp=Preg_Group,event=Miscarriage,class=Age_cat,ref=Age <32) ); /*0.*/ NOTE: PROC LOGISTIC is modeling the probability that Preg_Group='Miscarriage'. NOTE: Convergence criterion (GCONV=1E-8) satisfied. NOTE: There were 114 observations read from the data set WORK.IMPORT. NOTE: The data set WORK.ROC has 2 observations and 7 variables. NOTE: PROCEDURE LOGISTIC used (Total process time): real time 0.52 seconds cpu time 0.34 seconds 180: LINE and COLUMN cannot be determined. NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred. ERROR 180-322: Statement is not valid or it is used out of proper order. 87 88 %macro logitx(resp=,event=,x=,where=); 89 proc logistic data=import plots(only)=roc(id=prob); 90 where; 91 model &resp(event="&event") = &x /link=logit outroc=roc cl /*firth*/ rsquare rocci; 92 run; 93 %mend; 94 95 %logitx(resp=Preg_Group,event=Miscarriage,x=BMI); /*0.*/ NOTE: PROC LOGISTIC is modeling the probability that Preg_Group='Miscarriage'. NOTE: Convergence criterion (GCONV=1E-8) satisfied. NOTE: There were 114 observations read from the data set WORK.IMPORT. NOTE: The data set WORK.ROC has 98 observations and 8 variables. NOTE: PROCEDURE LOGISTIC used (Total process time): real time 0.50 seconds cpu time 0.25 seconds 96 %logitx(resp=Preg_Group,event=Miscarriage,x=Age); /*0.*/ NOTE: PROC LOGISTIC is modeling the probability that Preg_Group='Miscarriage'. NOTE: Convergence criterion (GCONV=1E-8) satisfied. NOTE: There were 114 observations read from the data set WORK.IMPORT. NOTE: The data set WORK.ROC has 18 observations and 8 variables. NOTE: PROCEDURE LOGISTIC used (Total process time): real time 0.40 seconds cpu time 0.23 seconds 97 98 title 'Mult Logistic Reg '; 99 proc logistic data=import plots(only)=roc(id=prob); where BMI_cat ^= 'BMI Other '; 100 class Age_cat(ref='Age <32')/param=ref; 101 model Preg_Group(event="Miscarriage") = BMI Age_cat Prog_1 102 /link=logit outroc=roc rsquare rocci cl/*nofit*/; 103 /*roc 'SIS ' SIS ;*/ 104 /*roc 'Sex PoinSD2 Temp' Gender Poincare_plot_SD2__ms_ Temperature_Reading__1_ ;*/ 105 /*roccontrast 'Compare'/estimate=allpairs;*/ 106 run; NOTE: PROC LOGISTIC is modeling the probability that Preg_Group='Miscarriage'. NOTE: Convergence criterion (GCONV=1E-8) satisfied. NOTE: There were 61 observations read from the data set WORK.IMPORT. WHERE BMI_cat not = 'BMI Other '; NOTE: The data set WORK.ROC has 61 observations and 8 variables. NOTE: PROCEDURE LOGISTIC used (Total process time): real time 0.47 seconds cpu time 0.28 seconds 107 108 109 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 121
Thank you!
Examine your code very very very carefully. One of your commands does not end with a semi-colon.
Hello!
Thanks for spotting it! I have rectified that line but the error still persists..
Show us the log after you have fixed the missing semi-colon.
Hello!
This is the log after adding the missing ;
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; NOTE: ODS statements in the SAS Studio environment may disable some output features. 73 74 libname mc '/folders/myfolders/research'; NOTE: Libref MC was successfully assigned as follows: Engine: V9 Physical Name: /folders/myfolders/research 75 76 proc import out= mc.complieddata datafile= "/folders/myfolders/Research/Master List 07062020 SAS.xlsx" 77 DBMS=xlsx Replace; 77 ! SHEET="Data Complied From Both Studies"; 78 GETNAMES=YES; 79 RUN; NOTE: Variable Name Change. Preg Group -> Preg_Group NOTE: Variable Name Change. Subject number -> Subject_number NOTE: Variable Name Change. Progestrone nmol/L -> Progestrone_nmol_L NOTE: Variable Name Change. Screen/Incl/Excl -> Screen_Incl_Excl NOTE: Variable Name Change. Enrollment Date -> Enrollment_Date NOTE: Variable Name Change. GA in weeks -> GA_in_weeks NOTE: Variable Name Change. F/U Date 16th Wk -> F_U_Date_16th_Wk NOTE: Variable Name Change. F/U Date 40th Wk -> F_U_Date_40th_Wk NOTE: Variable Name Change. 16 week miscarriage -> _16_week_miscarriage NOTE: Variable Name Change. 40 week miscarriage -> _40_week_miscarriage NOTE: Variable Name Change. Chromosomal Aberration (Y/N) -> VAR20 NOTE: Variable Name Change. Chromosomal Aberration (Descript -> Chromosomal_Aberration__Descript NOTE: Variable Name Change. Threatened Miscarriage (Y/N) -> VAR22 NOTE: Variable Name Change. Spontaneous Miscarriage (Y/N) -> VAR23 NOTE: Variable Name Change. IUGS & YS (Y/N) -> VAR24 NOTE: Variable Name Change. Completed? -> Completed_ NOTE: One or more variables were converted because the data type is not supported by the V9 engine. For more details, run with options MSGLEVEL=I. NOTE: The import data set has 168 observations and 27 variables. NOTE: MC.COMPLIEDDATA data set was successfully created. NOTE: PROCEDURE IMPORT used (Total process time): real time 0.21 seconds cpu time 0.14 seconds 80 81 data import; set research.import; 82 83 if Preg_Group in ('Miscarriage' 'Normal'); 84 85 if BMI >28 then BMI_cat = 'BMI >28 '; 86 else if 19 <= BMI < 23 then BMI_cat = '19<=BMI<23'; 87 else BMI_cat = 'BMI Other '; 88 89 if Age <32 then Age_cat = 'Age <32 '; 90 else if Age >= 32 then Age_cat = 'Age >=32'; 91 92 ln_Progestrone = log(Prog_1); 93 94 run; NOTE: There were 168 observations read from the data set RESEARCH.IMPORT. NOTE: The data set WORK.IMPORT has 114 observations and 30 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 95 96 title 'Cross tabulation on BMI and Age category groups'; 97 proc freq data=import; tables BMI_cat*Preg_Group/fisher; where BMI_cat ^= 'BMI Other '; run; NOTE: There were 61 observations read from the data set WORK.IMPORT. WHERE BMI_cat not = 'BMI Other '; NOTE: PROCEDURE FREQ used (Total process time): real time 0.32 seconds cpu time 0.30 seconds 98 proc freq data=import; tables Age_cat*Preg_Group/fisher; run; NOTE: There were 114 observations read from the data set WORK.IMPORT. NOTE: PROCEDURE FREQ used (Total process time): real time 0.21 seconds cpu time 0.19 seconds 99 100 101 run; 102 103 title 'Summary statistics'; 104 proc means data=import ndec=2 n mean std median p25 p75 min max; var Age GA_1 BMI; run; NOTE: There were 114 observations read from the data set WORK.IMPORT. NOTE: PROCEDURE MEANS used (Total process time): real time 0.16 seconds cpu time 0.15 seconds 105 106 title '2-sample t-test '; 107 proc ttest data=import; var Prog_1 ln_Progestrone; class Preg_Group; run; NOTE: PROCEDURE TTEST used (Total process time): real time 3.81 seconds cpu time 1.94 seconds 108 109 title 'Wilcoxon test rank sum test'; 110 title 'Summary statistics'; 111 proc means data=import ndec=2 n mean std median p25 p75 min max; var Age GA_1 BMI; run; NOTE: There were 114 observations read from the data set WORK.IMPORT. NOTE: PROCEDURE MEANS used (Total process time): real time 0.15 seconds cpu time 0.14 seconds 112 113 title; 114 proc npar1way data=import anova wilcoxon dscf plots(only)=anovaboxplot; 115 var BMI Age Prog_1 ; class Preg_Group; run; NOTE: DSCF multiple comparison analysis is available only when there are more than two CLASS levels. NOTE: PROCEDURE NPAR1WAY used (Total process time): real time 1.46 seconds cpu time 0.86 seconds 116 117 118 119 ods rtf file= "/folders/myfolders/Research/Master List 07062020 SAS.xlsx" 120 121 %macro logitc(resp=,event=,class=,ref=,where=); 122 proc logistic data=import plots(only)=roc(id=prob); 123 &where; 124 class &class(ref="&ref")/ param=ref; 125 model &resp(event="&event") = &class /link=logit outroc=roc cl /*firth*/ rsquare; 126 /*exact "&class" &class / estimate=parm;*/ 127 /*output out=outstats p=pred ;*/ 128 run; 129 %mend; 130 131 %logitc(resp=Preg_Group,event=Miscarriage,class=BMI_cat,ref=19<=BMI<23,where=BMI_cat ^= 'BMI Other '); /*0.*/ NOTE: Line generated by the invoked macro "LOGITC". 131 proc logistic data=import plots(only)=roc(id=prob); &where; class &class(ref="&ref")/ param=ref; model ____ ____ 22 22 202 76 131 ! &resp(event="&event") = &class /link=logit outroc=roc cl rsquare; run; NOTE: Line generated by the macro variable "WHERE". 131 BMI_cat ^= 'BMI Other ' _______ 180 ERROR 22-322: Syntax error, expecting one of the following: ;, ANCHOR, AUTHOR, BASE, BODY, BOOKMARK, BOX_SIZING, CHARSET, CLOSE, COLUMNS, CONTENTS, CSSSTYLE, DATAPANEL, DOM, DPI, ENCODING, FILE, FONTSCALE, GFOOTNOTE, GTITLE, HOST, IMAGE_DPI, KEEPN, LSTPIPE, NEWFILE, NOCONTENTS, NOGFOOTNOTE, NOGTITLE, NOKEEPN, NOLSTPIPE, NOOUTLINE, NOTRKEEP, OPERATOR, OUTLINE, PACKAGE, PATH, RECORD_SEPARATOR, SAS, SASDATE, SGE, STARTPAGE, STYLE, TEXT, TITLE, TRANTAB, TRKEEP. ERROR 202-322: The option or parameter is not recognized and will be ignored. ERROR 76-322: Syntax error, statement will be ignored. ERROR 180-322: Statement is not valid or it is used out of proper order. NOTE: Line generated by the invoked macro "LOGITC". 131 proc logistic data=import plots(only)=roc(id=prob); &where; class &class(ref="&ref")/ param=ref; model _____ 180 131 ! &resp(event="&event") = &class /link=logit outroc=roc cl rsquare; run; ERROR 180-322: Statement is not valid or it is used out of proper order. NOTE: Line generated by the invoked macro "LOGITC". 131 proc logistic data=import plots(only)=roc(id=prob); &where; class &class(ref="&ref")/ param=ref; model _____ 180 131 ! &resp(event="&event") = &class /link=logit outroc=roc cl rsquare; run; ERROR 180-322: Statement is not valid or it is used out of proper order. 132 %logitc(resp=Preg_Group,event=Miscarriage,class=Age_cat,ref=Age <32); /*0.*/ NOTE: PROC LOGISTIC is modeling the probability that Preg_Group='Miscarriage'. NOTE: Convergence criterion (GCONV=1E-8) satisfied. NOTE: There were 114 observations read from the data set WORK.IMPORT. NOTE: The data set WORK.ROC has 2 observations and 7 variables. NOTE: PROCEDURE LOGISTIC used (Total process time): real time 0.79 seconds cpu time 0.50 seconds 133 134 %macro logitx(resp=,event=,x=,where=); 135 proc logistic data=import plots(only)=roc(id=prob); 136 &where; 137 model &resp(event="&event") = &x /link=logit outroc=roc cl /*firth*/ rsquare rocci; 138 run; 139 %mend; 140 141 %logitx(resp=Preg_Group,event=Miscarriage,x=BMI); /*0.*/ NOTE: PROC LOGISTIC is modeling the probability that Preg_Group='Miscarriage'. NOTE: Convergence criterion (GCONV=1E-8) satisfied. NOTE: There were 114 observations read from the data set WORK.IMPORT. NOTE: The data set WORK.ROC has 98 observations and 8 variables. NOTE: PROCEDURE LOGISTIC used (Total process time): real time 0.69 seconds cpu time 0.39 seconds 142 %logitx(resp=Preg_Group,event=Miscarriage,x=Age); /*0.*/ NOTE: PROC LOGISTIC is modeling the probability that Preg_Group='Miscarriage'. NOTE: Convergence criterion (GCONV=1E-8) satisfied. NOTE: There were 114 observations read from the data set WORK.IMPORT. NOTE: The data set WORK.ROC has 18 observations and 8 variables. NOTE: PROCEDURE LOGISTIC used (Total process time): real time 0.63 seconds cpu time 0.39 seconds 143 144 title 'Mult Logistic Reg '; NOTE: PROCEDURE LOGISTIC used (Total process time): real time 0.00 seconds cpu time 0.00 seconds NOTE: The SAS System stopped processing this step because of errors. 145 proc logistic data=import plots(only)=roc(id=prob); where BMI_cat ^= 'BMI Other '; 146 class Age_cat(ref='Age <32')/param=ref; 147 model Preg_Group(event="Miscarriage") = BMI Age_cat Prog_1; 148 /link=logit outroc=roc rsquare rocci cl/*nofit*/; _ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 149 /*roc 'SIS ' SIS ;*/ 150 /*roc 'Sex PoinSD2 Temp' Gender Poincare_plot_SD2__ms_ Temperature_Reading__1_ ;*/ 151 /*roccontrast 'Compare'/estimate=allpairs;*/ 152 run; 153 154 155 156 157 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 169
Your ODS RTF statement is still missing the semicolon. FIX THAT FIRST.
You didn't end the ODS statement.
Why do you have WHERE statement without any conditioned being specified? Either remove it or give it an obviously true condition like:
WHERE 1=1;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.