BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Geo-
Quartz | Level 8

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

@Geo-

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();

View solution in original post

11 REPLIES 11
Kurt_Bremser
Super User

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.);
Geo-
Quartz | Level 8
sorry it's cacography,my code on the server is using "compress"
Geo-
Quartz | Level 8
sorry,for the whole log is on my server and can not connect to Internet.So I could only type letter by letter..the only message is this error..
Geo-
Quartz | Level 8
thank you for your patience..I mean we use intranet..
Kurt_Bremser
Super User

@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.

Patrick
Opal | Level 21

@Geo-

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();
gamotte
Rhodochrosite | Level 12
Hello,

Try removing the parentheses in the macro call :
%write_dx;
Oligolas
Barite | Level 11

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 -

Geo-
Quartz | Level 8
thank you!both of your answers pointed out

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 11 replies
  • 4185 views
  • 0 likes
  • 5 in conversation