DATA Step, Macro, Functions and more

select into macro variable - no row selected with single quotation mark

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 133
Accepted Solution

select into macro variable - no row selected with single quotation mark

why this marco doesn't work:

%macro t(var=);

proc sql;

select name into: name from sashelp.class where name='&var.';

quit;

%put _user_;

%mend;

%t(var=Henry);


what is wrong with my single quotation mark?




Accepted Solutions
Solution
‎03-01-2013 11:53 PM
Super User
Super User
Posts: 7,074

Re: select into macro variable - no row selected with single quotation mark

Macro language references are not expanded when enclosed in single quote marks. Use double quote character instead.

name = "&var"

View solution in original post


All Replies
Solution
‎03-01-2013 11:53 PM
Super User
Super User
Posts: 7,074

Re: select into macro variable - no row selected with single quotation mark

Macro language references are not expanded when enclosed in single quote marks. Use double quote character instead.

name = "&var"

Frequent Contributor
Posts: 133

Re: select into macro variable - no row selected with single quotation mark

is this the only main difference when choosing to use single or double quotation?

I always thought single/double quotation can be used interchangeably.

Respected Advisor
Posts: 3,156

Re: select into macro variable - no row selected with single quotation mark

Good topic for a SUG paper. Their differences seem to be more than just that. Especially when you refer Windows path ( X command, etc) or using SQL pass-thru ( well, to be fair, that is NOT a difference within SAS).

Haikuo

Frequent Contributor
Posts: 133

Re: select into macro variable - no row selected with single quotation mark

Is it safe to say that double quote is more generic than single quote in passing macro variables?

Super User
Super User
Posts: 7,074

Re: select into macro variable - no row selected with single quotation mark

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 237 views
  • 0 likes
  • 3 in conversation