DATA Step, Macro, Functions and more

PROC SQL insert issue with macro variable

Reply
Contributor
Posts: 33

PROC SQL insert issue with macro variable

I am constructing a little dataset based on some variables using SQL but I am having a problem with inserting the data with the contents of a variable.

This is what I have

Test dataset created...

%let testvar=XYZ;

PROC SQL;
insert into test;
values ('test field text &testvar. ');
quit;

This .sas file is not a macro? Does it have to be to translate the contents of the variable as it does not at the moment?

Thanks
Lee Message was edited by: Lee2010
Super Contributor
Posts: 474

Re: PROC SQL insert issue with macro variable

Posted in reply to LeeJenson
Hi.

Replace the single quotes with double quotes.

Macro variables do not get resolved to their values inside single quoting.

Cheers from Portugal.

Daniel Santos @ www.cgd.pt
SAS Super FREQ
Posts: 8,864

Re: PROC SQL insert issue with macro variable

Posted in reply to LeeJenson
Hi:
In addition to Daniel's advice, you might find this paper useful. It contains an overview of the SAS Macro Facility:
http://www2.sas.com/proceedings/sugi28/056-28.pdf

cynthia
Contributor
Posts: 33

Re: PROC SQL insert issue with macro variable

Posted in reply to Cynthia_sas
Sorry...
that's twice that has caught me out and you have provided me with the answer.

Thanks

Lee
Ask a Question
Discussion stats
  • 3 replies
  • 143 views
  • 0 likes
  • 3 in conversation