Hi all. We have a list of emails that I'm trying to store in a table that looks something like this:
"ironman@marvel.com" "thor@marvel.com" "hulk@marvel.com"
which is passed onto a macro var &team. It is then called out in a proc sql that looks like this:
proc sql;
create table avengers as
select
"&team." as members
from earth
;
quit;
However SAS sees the double quotes and gets all confused. It won't let me use single quotes. I've tried compress and tranwrd, those are not working either. Any help is appreciated.
@Vestax have you tried translate instead of trnwrd?
%let k="ironman@marvel.com""thor@marvel.com""hulk@marvel.com";
%put &k;
%let k1=%sysfunc(translate(%superq(k),%str( ),%str(%")));
%put &k1 ;
I think somebody who is senior and wiser would prolly even suggest a better design of the data flow process or even table design. The manual operation seems wary. But anyway up to you.
Not sure, as I don't comprehend the flow of data in your process but a simple demo
%let k="ironman@marvel.com" "thor@marvel.com" "hulk@marvel.com";
%put &k;
%let k1=%sysfunc(compress(%superq(k),%str(%")));
%put &k1 ;
@novinosrin wrote:Not sure, as I don't comprehend the flow of data in your process but a simple demo
%let k="ironman@marvel.com" "thor@marvel.com" "hulk@marvel.com"; %put &k; %let k1=%sysfunc(compress(%superq(k),%str(%"))); %put &k1 ;
We're trying to store the string in the macro variable as an observation. Your solution works somewhat but what if there are no spaces and the data coming in looks like
%let k="ironman@marvel.com""thor@marvel.com""hulk@marvel.com";
Is it possible to add spaces or remove the double quotes without compressing the spaces?
Any reason you can’t do this instead:
select &team as members....
@Vestax have you tried translate instead of trnwrd?
%let k="ironman@marvel.com""thor@marvel.com""hulk@marvel.com";
%put &k;
%let k1=%sysfunc(translate(%superq(k),%str( ),%str(%")));
%put &k1 ;
I think somebody who is senior and wiser would prolly even suggest a better design of the data flow process or even table design. The manual operation seems wary. But anyway up to you.
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.
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.