Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Proc sql with macro variable help

Status
Not open for further replies.

upspeaker1

Programmer
Nov 24, 2009
1
GB
I'd like some help constructing a proc sql step. I have a query like

PROC SQL;
SELECT title, rating, category
FROM movies
WHERE category LIKE 'D%';
QUIT;

What I'd like to do is make the D a macro variable i.e change at run time depending on user input but retain the % sign. Do I need to use a quoting function? If so which one; I have tried using %SUPERQ, %NRSTR, %STR, %BQUOTE, %NRBQUOTE and none of them worked. Would be very glad for any help with this.

Rgds
 
You have to use double quotes(") instead of of single quotes(') when you have a variable that needs a quotes around it.
Code:
%LET Var = D;

PROC SQL;
  SELECT title, rating, category
    FROM movies
      WHERE category LIKE "&var.%";
QUIT;
Hope this helps.
Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top