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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.