- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
PC SAS 9.4 m7.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use a valid name for your macro. Names in SAS are limited to 32 bytes. (There is no need to write a novel in a name.)
Also avoid hiding continuation characters at the END of the lines of code. Place them at the BEGINNING of the lines where they are much, much easier for HUMANS to scan.
1 %macro sweet_spot_and_confidence_all_folds ERROR: Invalid macro name SWEET_SPOT_AND_CONFIDENCE_ALL_FOLDS. It should be a valid SAS identifier no longer than 32 characters. ERROR: A dummy macro will be compiled. 2 (libname=SAS_1 3 ,response_variable=i_016 4 ,predictor1=i_127 5 ,predictor2=i_128 6 ,k_folds=5 7 ,report_file=final_report_%sysfunc(today(), yymmdd10.).txt 8 ); 9 %put _local_; 10 %mend; 11 %sweet_spot_and_confidence_all_folds ; - 180 ERROR 180-322: Statement is not valid or it is used out of proper order.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It appears your macro is generating SAS code containing syntax errors, hence the "Statement is not valid" error.
Try adding the MPRINT option to provide more evidence, then post your complete SAS log showing the generated code along with any errors:
options mprint;
%confidence_all_folds(libname=SAS_1, response_variable=i_016, predictor1=i_127, predictor2=i_128, k_folds=5);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Did you compile the macro in your current SAS session?
That would mean executing the code that starts %macro confidence_all_folds and ends with %mend.
Did is compile without errors? If the compilation step has errors or was not executed in the current session then the macro is not defined in the session in will return that error message.
If you didn't run the code then you need to find the code that defines the macro and execute it.
See this log for an attempt to execute a macro that I know has not been compiled in my current SAS session:
928 %dummymac (lib=jimmy); - 180 WARNING: Apparent invocation of macro DUMMYMAC not resolved. ERROR 180-322: Statement is not valid or it is used out of proper order.
It also appears that you perhaps edited the LOG from your attempt.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This appears to the start of the macro. Seems this might be where the error is. If so, it needs to be edited in some way. The error (??) is probably preventing the macro from being 'compiled' in the current session:
%macro sweet_spot_and_confidence_all_folds(
libname=SAS_1,
response_variable=i_016,
predictor1=i_127,
predictor2=i_128,
k_folds=5,
report_file=final_report_%sysfunc(today(), yymmdd10.).txt
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use a valid name for your macro. Names in SAS are limited to 32 bytes. (There is no need to write a novel in a name.)
Also avoid hiding continuation characters at the END of the lines of code. Place them at the BEGINNING of the lines where they are much, much easier for HUMANS to scan.
1 %macro sweet_spot_and_confidence_all_folds ERROR: Invalid macro name SWEET_SPOT_AND_CONFIDENCE_ALL_FOLDS. It should be a valid SAS identifier no longer than 32 characters. ERROR: A dummy macro will be compiled. 2 (libname=SAS_1 3 ,response_variable=i_016 4 ,predictor1=i_127 5 ,predictor2=i_128 6 ,k_folds=5 7 ,report_file=final_report_%sysfunc(today(), yymmdd10.).txt 8 ); 9 %put _local_; 10 %mend; 11 %sweet_spot_and_confidence_all_folds ; - 180 ERROR 180-322: Statement is not valid or it is used out of proper order.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Then show the LOG where the compilation takes place, or the result that it compiled without errors.
If we need to debug the actual contents of the macro then you will have to share the code for the entire macro.
Experience for a few years of using macro code (only since 1992) tells me if I assume that the cause of the reported macro error is the statement the SAS compiler reports as a problem then I will be wrong roughly half the time. Quite often macro compilation errors are caused by logic errors prior to the proximate line(s) that SAS reports with an error. Usually because the prior logic error created a value or condition that fails to compile.
P.S. If your Report_file is an actual external to SAS file name I would suggest using the YYMMDDN8. format instead of YYMMDD10. The N means no separator so you get names that look like "final_report20240820.txt" instead of "final_report2024/08/20.txt" which might get interpreted as a different file path than you expect.
@NKormanik wrote:
This appears to the start of the macro. Seems this might be where the error is. If so, it needs to be edited in some way. The error (??) is probably preventing the macro from being 'compiled' in the current session:
%macro sweet_spot_and_confidence_all_folds(
libname=SAS_1,
response_variable=i_016,
predictor1=i_127,
predictor2=i_128,
k_folds=5,
report_file=final_report_%sysfunc(today(), yymmdd10.).txt
);