BookmarkSubscribeRSS Feed
Liliya95
Fluorite | Level 6

how I can pass comma in macro parameter?

....
%do i=1 %to &count; 
%let data =%sysfunc(inputc("&&base64code&i", $base64x32767));

%let DOCFILE = &PATH./Doc.&i..xml;
        FILENAME DOCFILE "&DOCFILE" encoding='wcyrillic' LRECL=32767;
        data _null_;
          
          file DOCFILE LRECL=32767;
          length temp $32767;
          put "&data";

        run;

%end;

 

 

I have error:

ERROR:Literal contains unmatched quote.

 

But %superq() have the same mistake.

%let data =%superq(%sysfunc(inputc("&&base64code&i", $base64x32767)));

 

 

And %NRBQUOTE() have  error:

ERROR 616-185: Character constant truncated to 32767 characters.

 

what I do wrong?

9 REPLIES 9
PaigeMiller
Diamond | Level 26

You have unmatched quote. It may or may not have anything to do with the comma.

 

But we can't give you any more help until you show us your code.

--
Paige Miller
Liliya95
Fluorite | Level 6
I add code in post
SuryaKiran
Meteorite | Level 14

Show us your code that creating error to assist further.

Thanks,
Suryakiran
Liliya95
Fluorite | Level 6
add code in post
Astounding
PROC Star

Things to test because they look strange ....

 

At the bottom of your posted code, END should be %END.  That might just be an oversight in what you posted.

 

Macro language doesn't use quotes to identify character strings.  Get rid of the double quotes within the first parameter to the INPUTC function.

Liliya95
Fluorite | Level 6
Yes, it's oversight in what I posted.
I can't use to INPUTC function. Because text &base64code&i - encode text, and doesn't have double quotes
Astounding
PROC Star

I'm not sure what it is that you are saying you can't do.  The quotes should come out.  Here's a sample program to demonstrate:

 

proc format;
invalue $test 'abc' = 'xyz';
run;

%let before=abc;

%let after = %sysfunc(inputc(&before, $test.));

%put _user_;
RW9
Diamond | Level 26 RW9
Diamond | Level 26

There is a fair bit which looks dubious in this code.  Line 2 for instance, it is bad coding to use SAS reserved keywords as variable names, so data is a reserved keyword.  nExT uP is COdiNG like that.  Use consistent lower case and consistent indetation to make code readable.

Now for your issue, can you provide some simple test data in the form of a datastep, so that we have something to work with.  From what i can tell you want to create &count. number of xml files, so it may well be simpler to do:

data _null_;
  do i=1 to &count.;
    call execute(cat('data _null_;  
                        file docfile "&docfile." encoding="wcyrillic" lrecl=32767;
                        put "',inputc(...,$base65x32767),'";
                      run;'));
  end;
run;

However this opens several more questions just typing that in.  Why are you creating XML files - given by the filetype - yet the output you create is not XML?  What is &&base64code&i?  Why is it such a complicated inputc and encoding, does normal utf8 or 16 not suffice?  Why the maximum line length?  XML can handle end of line characters and indents and such like just fine, so write a nice readable XML file one record at a time by hand or use a dataset and the XML engine to write it out?  Sounds a bit like your creating all the XML into one big macro variable which is not a good idea.

Tom
Super User Tom
Super User

Your posted code has neither commas nor macro parameters.

 

But to answer you question.

1) Don't.  Why would you want to pass in commas in the value of a macro parameter?  If you need to pass in a list use a space or some other character as the delimiter in the list.

2) If you must you need to "protect' the comma in some way.

 

You can add quotes or parenthesis to the value. Just remember to either remove them (or don't add them) when you use the value. Or as a LAST resort you can add macro quoting around the value (or just the troubling values).

%mymacro
(parm1=space delimited list
,parm2=pipe|delimited|list
,parm3='single,quoted,list'
,parm4="double,quoted,list"
,parm5=(parentheses,around,list)
,parm6=%str(macro,quoted,list)
);

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 9 replies
  • 1716 views
  • 0 likes
  • 6 in conversation