Why won't my macro variable resolve?
NickName:Joe Ask DateTime:2015-01-14T23:16:17

Why won't my macro variable resolve?

I have a macro variable, &myvar, but it won't resolve when I try to put it in a data step variable. Why won't it, and what can I do to fix this?

%let myvar=Hello, world;
data _null_;
  x='&myvar.';
  put x=;
run;

Copyright Notice:Content Author:「Joe」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/27946244/why-wont-my-macro-variable-resolve

Answers
Joe 2015-01-14T15:16:17

Macro variables in SAS won't resolve when they are in single quotes, '&myvar'. They need to be in double quotes, \"&myvar\", in order to resolve properly.\n\nIf you need to have single quotes and a resolved macro variable, you have a few options, but the simplest is:\n\n%str(%'&myvar.%')\n\n\nThe %' inside of %str will place a single quote character (or apostrophe) in the text string by itself without causing it to be quoted.\n\ndata _null_;\n x=\"%str(%'&myvar.%')\";\n put x=;\nrun;\n\n\nor\n\n%let myvar2 = %str(%'&myvar.%');\n",


More about “Why won't my macro variable resolve?” related questions

Why won't this code work?

Can anyone tell me why this code won't work? <?php $err=1; ?> <img src="334234234234234.gif" onError="<?php $err=0; ?>" /> <?php echo "<br /&a

Show Detail

Why won't this code work?

This is a simple actionscript code. Why won't it work? for (var inc = 1; inc <= 18; inc++) { current = "cb"+inc; current.addEventListener(Event.CHANGE, storedata); }

Show Detail

Why won't my macro variable resolve?

I have a macro variable, &myvar, but it won't resolve when I try to put it in a data step variable. Why won't it, and what can I do to fix this? %let myvar=Hello, world; data _null_; x='&

Show Detail

Why won't my macro variable resolve?

I have a macro variable, &myvar, but it won't resolve when I try to put it in a data step variable. Why won't it, and what can I do to fix this? %let myvar=Hello, world; data _null_; x='&

Show Detail

Why won't my macro variable resolve?

I have a macro variable, &myvar, but it won't resolve when I try to put it in a data step variable. Why won't it, and what can I do to fix this? %let myvar=Hello, world; data _null_; x='&

Show Detail

Why this .htaccess with 1 variable won't work?

I'm trying to get this but i really don't know why won't work. I try to change things and params and won't work: RewriteCond %{QUERY_STRING} board=([0-9]+).0 RewriteRule ^forum/index\.php$ index.php?

Show Detail

Why won't it print this variable?

So I'm doing this thing for math that requires a detailed algorithim. The thing is, it won't actually print the answer, and I don't know why. Essentially, the game that we have to find a strategy t...

Show Detail

Why won't ifstream open this file?

#include <iostream> #include <fstream> using namespace std; #define BRIGHTNESS_FILE "/sys/class/backlight/radeon_b10/brightness" int main() { ifstream brightness_file("

Show Detail

Why won't my DIV be 100% height?

I'm using Twitter's bootstrap "well" ID in a DIV and added my own "STYLE" in the HTML TAG but it won't seem to go 100% height? style="width:65%; height:100%; display:inline-block; margin-top:60px;...

Show Detail

Why won't this print out anything?

Why won't this print out anything, but it works if i just use (print "ASDAS") ,I'm using LightTable and It's printint out in the console. (defn try [x] (print ("ASDASD") )) (try 5)

Show Detail