BookmarkSubscribeRSS Feed
excelsas
Calcite | Level 5
I have written a macro to split a large dataset into several states datasets but getting an error message for OR (Oregon) state as it is a boolean operator but working fine for NE(Nebraska) state.
I tried %quote but it did not work.


%quote(&state)=%str(OR)

Any suggestion would be appreciated.

Also I used Proc format and value to change the values of a variable in the main datasets but the values are unchanged in the states datasets.
What should I use to change the values permanently?


Thanks,
3 REPLIES 3
Ksharp
Super User
Have you used %superq() ?



Ksharp
DBailey
Lapis Lazuli | Level 10
Within macros, I often have to use the double quote like this:

"&State."="OR"

I know there are sometimes issues with the variables have extraneous characters, but if the domain is known, this might work.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
%quote(...) with %str(..) works -- also a technique I sometimes use is to simply append a period/dot character in the expression to remove the resemblence of a Boolean operator, such as shown below.

Scott Barry
SBBWorks, Inc.


%macro x(state);
%if %quote(&state) = %str(OR) %then %put yep;
%else %put nope;
%Mend x;
%x(NE);

%macro x(state);
%if .&state = .OR %then %put yep;
%else %put nope;
%Mend x;
%x(OR);

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1349 views
  • 0 likes
  • 4 in conversation