BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
metallon
Pyrite | Level 9

Hi SAS Experts,

 

I am creating a macro variable %LET RepQuarter = '4th (October-December)'; and insert it later on

in my custom ods xml tagset.

 

        define event EmitMetaMainMessage;
            xdent;
            put "</Metas>" CR;
            put "<main>" CR;
            put "<year>&RepYear" ;
            put "</year>" CR;
            put "<quarter>&RepQuarter" ;
            put "</quarter>" CR;
        end;

 

But I need it without the quotes'. How can I remove those?

 

Bye

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

Agree with @RW9 about not adding the quotes in the first place.  But if you want to remove them, you can use the DEQUOTE function.

 

1    %LET RepQuarter = '4th (October-December)';
2
3    data _null_;
4      put "<quarter>&RepQuarter" ;
5      put "<quarter>%sysfunc(dequote(&RepQuarter))" ;
6    run;

<quarter>'4th (October-December)'
<quarter>4th (October-December)

 

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

View solution in original post

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

Hi,

 

Why have you put quotes on it in the first place?

%LET RepQuarter = 4th (October-December);

Problem solved.  The next question is, why is data in a macro parameter?

metallon
Pyrite | Level 9
Greetings!
Unfortunately the problem is not solved be removing the quotes:

NOTE: Line generated by the macro variable "REPQUARTER".
252 4th (October-December)
__
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

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

The next question is not really a problem I have. I use the variable at various points in the code.
metallon
Pyrite | Level 9
Hi RW9,

The problem is not solved by removing the quotes.

NOTE: Line generated by the macro variable "REPQUARTER".
252 4th (October-December)
__
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

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

The second question is not really a problem I have. I just use the macro at various places in the code.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yes, but then you haven't thought about the data, and the process then have you.  If you need parameters, put them into a dataset, its is far easier to work with.  Datasets are there to work with Data, macro variables are there as find and replace, and as you are seeing in your example, that find and replace fails as you are using it in multiple ways.

Quentin
Super User

Agree with @RW9 about not adding the quotes in the first place.  But if you want to remove them, you can use the DEQUOTE function.

 

1    %LET RepQuarter = '4th (October-December)';
2
3    data _null_;
4      put "<quarter>&RepQuarter" ;
5      put "<quarter>%sysfunc(dequote(&RepQuarter))" ;
6    run;

<quarter>'4th (October-December)'
<quarter>4th (October-December)

 

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

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
  • 5 replies
  • 13369 views
  • 2 likes
  • 3 in conversation