BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have what I think is a quoting problem. In the code below the PUT/SELECT statement doesn't work because the macro variables are inside single quotes. Is there a way around this?


filename cmds dde "excel|system";
data file3x_reformat;
file cmds;
%macro reformat;
%do i=1 %to &count_header;
%let selectcmd =
put '[select("R&&Header&I..C1:R&&Header&I..C1")]';
put '[font.properties("MS Sans Serif","Bold",10,,,,,,,1)]';
%end;
%mend reformat;
%reformat;
run;
4 REPLIES 4
CurtisMack
Fluorite | Level 6
I've had luck putting a single quote in a marco var and using it instead of quotes in the put statements. Something like this (untested because I don't have your data).

%let q = %nrstr(%');
%put &q;

filename cmds dde "excel|system";
data file3x_reformat;
file cmds;
%macro reformat;
%do i=1 %to &count_header;
%let selectcmd =
put &q.[select("R&&Header&I..C1:R&&Header&I..C1")]&q.;
put &q.[font.properties("MS Sans Serif","Bold",10,,,,,,,1)]&q.;
%end;
%mend reformat;
%reformat;
run;

Curtis
deleted_user
Not applicable
Curtis,

Thanks for your reply. When I run your code I get the following errors:



371 put &q.[select("R&&Header&I..C1:R&&Header&I..C1")]&q.; put
______
68
371 ! '[font.properties("MS Sans Serif","Bold",10,,,,,,,1)]';
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, arrayname,
#, (, +, /, //, ;, @, @@, OVERPRINT, _ALL_, _BLANKPAGE_, _ODS_, _PAGE_.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR 68-185: The function SELECT is unknown, or cannot be accessed.

ERROR: Undeclared array referenced: NAME.

_
22
200
CurtisMack
Fluorite | Level 6
I suspected that would happen, but I did not know what the rest of the code would do.

I think what you might really want to do is use double quotes and then double them up when you want one inside the string.

data file3x_reformat;
file cmds;
%macro reformat;
%do i=1 %to &count_header;
%let selectcmd =
put "[select(""R&&Header&I..C1:R&&Header&I..C1"")]";
put "[font.properties(""MS Sans Serif"",""Bold"",10,,,,,,,1)]";
%end;
%mend reformat;
%reformat;
run;

This assumes that your code has a pseudo macro array of HEADER1 - HEADER&count_header;
deleted_user
Not applicable
Thanks Curtis, that worked!

Jeff

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 1802 views
  • 0 likes
  • 2 in conversation