BookmarkSubscribeRSS Feed
Rohit12
Obsidian | Level 7

%let aa="[email protected]"  "[email protected]";

%put &aa;

 

data new;

zz=translate("&aa","@","$");

run;

 

NOTE: Line generated by the macro variable "AA".

1    ""[email protected]"  "[email protected]"

     ---

     216

        -----

        388

        76

ERROR 216-185: The use of a BIT string constant is not allowed in this context.

 

ERROR 388-185: Expecting an arithmetic operator.

 

ERROR 76-322: Syntax error, statement will be ignored.

 

72   run;

 

Question : what does this error mean " The use of a BIT string constant is not allowed in this context."

 

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Your error comes from having quotes in your macro variable:

%let aa="[email protected]"  "[email protected]";

 

Look at what is generated:

data new;

zz=translate(""[email protected]"  "[email protected]"","@","$");

run;

See the double quotes?

 

As always, I advise against putting lists of values in macro variables, data should go in datasets - clue is in the name.  And really don't put commas or quotes and things in macro variables at any time.

Rohit12
Obsidian | Level 7

Hello 

 

Actually values in macro variable  always will be in double quotes . I am working on some code which is working from long time and I cannot chnage that 

 

Should we have other solution rather than removing double quotes 

 

Thanks!!

Shmuel
Garnet | Level 18

You can overcome the quotes problem by using sysmget function:

 

%let aa="[email protected]"  "[email protected]";

data _null_;
    aa = symget('aa');
    aa = translate(aa,'$','@');
    put aa=;
run;
Rohit12
Obsidian | Level 7
actually I am passing this value [email protected]" "[email protected]" as a postional parameter in the macro so I think I cannot use symget

Anyother way of passing this value
Shmuel
Garnet | Level 18

You posted next code:

 

data new;

zz=translate("&aa","@","$");

run;

 

you need change one line:

 

data new;

zz=translate(symget("&aa"),"@","$");

run;

 

By the way, your macro variable &aa contains already @

if you want to translate it into $ you should write:

zz=translate(symget("&aa"),"$","@");

 

 

AI Navigator GIF.gif


Navigate AI governance with SAS tools for compliance and ethical AI practices. Try SAS Ai Navigator for free for the first six months.

Check it out on Microsoft Marketplace →

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 5415 views
  • 5 likes
  • 3 in conversation