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

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