I have searched some info about this error,but it seems none match mine,may someone familiar with this error take a look.
"Code generated by a SAS macro, or submitted with a "submit selected" operation in your editor, can leave off a semicolon inadvertently." it is still abstruse for me to explore in my code by this comment.may someone give any advice..thanks!
%let cnt=500;
%let dataset=fund_sellList;
%let sclj='~/task_out_szfh/fundSale/';
%let wjm='sz_fundSale_';
%macro write_dx;
options spool;
data _null_;
cur_date=put(today(),yymmdd10.);
cur_date=compress(cur_date,'-');
cnt=&cnt;
retain i;
set &dataset;
if _n_=1 then i=cnt;
if _n_<=i then do;
abs_filename=&sclj.||&wjm.||cur_date||'.dat';
abs_filename=compress(abs_filename,'');
file anyname filevar=abs_filename encoding='utf8' nobom ls=32767 DLM='|';
put cst_id @;
put '@|' @;
put cust_name @;
put '@|' ;
end;
run;
%mend write_dx;
%write_dx();
and if I am not using macro,there is no error.
data _null_;
options spool;
cur_date=put(today(),yymmdd10.);
cur_date=compress(cur_date,'-');
cnt=&cnt;
retain i;
set &dataset;
if _n_=1 then i=cnt;
if _n_<=i then do;
abs_filename=&sclj.||&wjm.||cur_date||'.dat';
abs_filename=compress(abs_filename,'');
file anyname filevar=abs_filename encoding='utf8' nobom ls=32767 DLM='|';
put cst_id @;
put '@|' @;
put cust_name @;
put '@|' ;
end;
run;
The error message itself is pretty clear and you'll get it if you either use a SAS statement that doesn't exist or if there has been an error right before your statement which "confused" the compiler so it can't recognize the valid statement anymore.
When using SAS Macro language then basically the SAS Macro generates SAS code and then the SAS code gets compiled and executed. So if the macro generates wrong SAS code then you can get such an error message.
Having said all of the above: I couldn't really see something wrong in your code so I had to create some sample data and run it.
...the reason why things are not working for you:
You define the macro without parameters and without a bracket BUT you call it with a bracket. To avoid the error either use brackets or don't (I prefer using brackets always).
So to fix your code the only thing you need to do is to change your macro definition as below:
%macro write_dx();
Get your SAS code to run properly before wrapping it in a macro.
Since your macro has no macro-specific code, and uses no macro parameters, it is not needed anyway.
Removing the macro definition will enable the syntax coloration of your Studio or Enterprise Guide, and looking at the log will show you that SAS complains about
comress
in line
cur_date=comress(cur_date,'-');
which is not a SAS function. I guess you wanted to use compress().
And you don't need compress at all if you use the proper format:
cur_date = put(today(),yymmddn8.);
Then copy/paste the log as described in https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce
Open the log window.
Mark the relevant section.
Hit Ctrl-C.
Switch to the browser, hit Ctrl-V.
Any text displayed in Windows can be copy/pasted that way.
@Geo- wrote:
thank you for your patience..I mean we use intranet..
And?
Text on your screen can be copy/pasted. I guess your intranet is not sending you stone plates with text chiseled in.
The error message itself is pretty clear and you'll get it if you either use a SAS statement that doesn't exist or if there has been an error right before your statement which "confused" the compiler so it can't recognize the valid statement anymore.
When using SAS Macro language then basically the SAS Macro generates SAS code and then the SAS code gets compiled and executed. So if the macro generates wrong SAS code then you can get such an error message.
Having said all of the above: I couldn't really see something wrong in your code so I had to create some sample data and run it.
...the reason why things are not working for you:
You define the macro without parameters and without a bracket BUT you call it with a bracket. To avoid the error either use brackets or don't (I prefer using brackets always).
So to fix your code the only thing you need to do is to change your macro definition as below:
%macro write_dx();
Hi,
when not using macro parameters, add brackets to the macro name definition
%macro write_dx();
or remove the brackets in the macro call
%write_dx;
to fix the error. I prefer for my part option 1.
- Cheers -
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.