Hi Experts,
Here I am trying to extract only delimiters names from the below dataset using proc sql into clause
suppose we have multiple delimiters are there in huge data how to achieve dynamically
data cricketers;
input name$70.;
cards;
Curtyly Ambrose
Neil,Fairbrother
Kenny#Benjamin
sachin tendulkar
sunil gavaskar
Rohan,Gavaskar
Dhoni
virat
;
run;
proc sql noprint;
select name into :delimeter_names separated by ' '
from cricketers
where index(name, ',') > 0 or index(name, '#') > 0;
quit;
%put &delimeter_names;
You could try FINDC() .
data cricketers;
input name$70.;
cards;
Curtyly Ambrose
Neil,Fairbrother
Kenny#Benjamin
sanchi tendulkar
sunil gavaskar
Rohan,Gavaskar
Dhoni
virat
;
run;
proc sql noprint;
select name into :delimeter_names separated by ' '
from cricketers
where findc(name,',','p') > 0;
quit;
%put &delimeter_names;
You could try FINDC() .
data cricketers;
input name$70.;
cards;
Curtyly Ambrose
Neil,Fairbrother
Kenny#Benjamin
sanchi tendulkar
sunil gavaskar
Rohan,Gavaskar
Dhoni
virat
;
run;
proc sql noprint;
select name into :delimeter_names separated by ' '
from cricketers
where findc(name,',','p') > 0;
quit;
%put &delimeter_names;
What will you be doing with this list of data later on?
Putting a mass of data (particularly when it contains delimiting characters which can wreck a macro call) into a macro variable is, in the large majority of cases, a BAD IDEA.
Data is best kept in datasets.
PS you yourself talk about "huge data", so this can very easily crack the 64k limit of macro variables. Forget the macro variable approach.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.
Ready to level-up your skills? Choose your own adventure.