From: SAS User on
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
From: Tom Abernathy on
Macro variables are not expanded inside of single quotes. Use double
quotes.
"test field text &testvar"

On Feb 8, 8:17 am, SAS User <sasuser2...(a)googlemail.com> wrote:
> 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

From: shiva on
Hi Lee,

Remove semicolon after test and try this..

%let testvar=XYZ;

data test;
input test $ 30.;
cards;
example
;
run;
PROC SQL;
insert into test
values ("test field text &testvar.");
quit;

Thanks,
-Shiva