5

I am trying to use a variable on PROC SQL but i cannot find a proper way through the internet. I just want to apply the following code of T-SQL on PROC SQL:

 declare @example as int;
set @example=2;
select * from {table} where {column}=@example;
go

How can i apply this code on PROC SQL?

Joe
  • 62,789
  • 6
  • 49
  • 67
dimos
  • 147
  • 2
  • 9

1 Answers1

6

The translation to SAS SQL is to use a macro variable, the code looks pretty similar, need to wrap it in a PROC SQL block though.

%let example=2;

proc sql;
select *
from table
where variable=&example;
quit;

EDIT: my original reference to the macro variable was incorrect, use an ampersand in SAS not @ symbol.

Reeza
  • 20,510
  • 4
  • 21
  • 38
  • Many thanks, i could not find that implementation through the web. I was able to find only implementations with really MANY lines of code which is quite irritating. Do you have in your mind any specific Book or guide for SAS SQL? i can only find books that are not helpful – dimos Dec 04 '15 at 21:22
  • Here's a quick decent intro in SAS Macros. http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/ – Reeza Dec 04 '15 at 21:22