BookmarkSubscribeRSS Feed
LeeJenson
Calcite | Level 5
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
3 REPLIES 3
DanielSantos
Barite | Level 11
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
Cynthia_sas
SAS Super FREQ
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
LeeJenson
Calcite | Level 5
Sorry...
that's twice that has caught me out and you have provided me with the answer.

Thanks

Lee

SAS Innovate 2025: Register Today!

 

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1101 views
  • 0 likes
  • 3 in conversation