BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
yashpande
Obsidian | Level 7

Hi All,

I have 4 macro variables which I want to use in Teradata SQL passthrough, since TD doesnt recognise double quotes, my challenge is to create them in single quotes.somehow I am unable to do it since few of them have missing values as well.

My macro variables are like this

%let var1=abc;

%let var2=pqr;

%let var3=;

%let var4=new;

I want to use it something like this in my proc sql

case when var1 eq 'abc' and var2 eq 'pqr' and var3 eq '' and var4 eq 'new' then true;

Any help is really appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
yashpande
Obsidian | Level 7

Got it working with something like this

%let var1_n=%unquote(%bquote(')&var1%bquote('));

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

Does something like this help:

%let var1 = abc;

%put case when var1 eq %str(%')&var1%str(%');

Scott_Mitchell
Quartz | Level 8

%LET VAR1='ABC';

%LET VAR2='PQR';

%LET VAR3='';

%LET VAR4='NEW';

PROC SQL;

CREATE TABLE TEST AS

SELECT *,

CASE WHEN VAR1 EQ &VAR1. AND VAR2 EQ &VAR2. AND VAR3 EQ &VAR3. THEN 1 END AS FLAG

FROM HAVE

;

RUN;

Why not surround your macro variable values in single quotes?

yashpande
Obsidian | Level 7

Got it working with something like this

%let var1_n=%unquote(%bquote(')&var1%bquote('));

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3469 views
  • 6 likes
  • 3 in conversation