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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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