BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
pavank
Quartz | Level 8

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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;

View solution in original post

2 REPLIES 2
Ksharp
Super User

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;
Kurt_Bremser
Super User

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.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

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.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 654 views
  • 4 likes
  • 3 in conversation