BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
arodriguez
Lapis Lazuli | Level 10

Hi everyone,

 

In a macro I concatenate multiple levels. Seems that one of thats levels have a "%", as a separator i use "#" character and I get differents outputs depending on if I put or not " ".

 

Here an example

%let var=Test;
%let array=%;
%put &array.#&var.;
%#Test#Test
%put &array.# &var.;
%# Test
%put &array. #&var.;
% #Test #Test

Someone know Why this odd performance? It seems a strange performance that is not presented when there is not the "%"

 

Thanks

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jklaverstijn
Rhodochrosite | Level 12

Hi @arodriguez,

 

Once you have come to gripsd with th emacro facility this behaviour will no longer seem strange. The % sign is what's called a type 3 macro trigger. It has special meaning for the macro facility and will throw things off if not properly stripped from that meaning.

 

Try coding 

 

%let array=%nrbquote(%);

and your code will run a lot better.  (edited from %nrstr(%%) to %nrbquote(%) which is even better)

 

For background I suggest you read up on macro quoting, an advanced subject indeed. But there are many good resources om the web.

 

Hope this helps,

- Jan.

View solution in original post

2 REPLIES 2
jklaverstijn
Rhodochrosite | Level 12

Hi @arodriguez,

 

Once you have come to gripsd with th emacro facility this behaviour will no longer seem strange. The % sign is what's called a type 3 macro trigger. It has special meaning for the macro facility and will throw things off if not properly stripped from that meaning.

 

Try coding 

 

%let array=%nrbquote(%);

and your code will run a lot better.  (edited from %nrstr(%%) to %nrbquote(%) which is even better)

 

For background I suggest you read up on macro quoting, an advanced subject indeed. But there are many good resources om the web.

 

Hope this helps,

- Jan.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

The question really is why are you doing that, are you trying to make unreadable code?

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