Hello,
I have a question please. Is it right to write the code:
where cd_produit like '%PE%GB%';
if I want to find the products like PE01GB, PE33GB, PE67GB
Thank you very much!
Hello,
Why don't you test it and check if it suits your needs ?
data have;
input cd_produit $20.;
cards;
PE01GB
PE67GB
PA45GB
PE35GC
AAPE75GBCC
PEZZGB
;
run;
data want;
set have;
where cd_produit like '%PE%GB%';
run;
Hello,
Why don't you test it and check if it suits your needs ?
data have;
input cd_produit $20.;
cards;
PE01GB
PE67GB
PA45GB
PE35GC
AAPE75GBCC
PEZZGB
;
run;
data want;
set have;
where cd_produit like '%PE%GB%';
run;
Glad it helped.
There are always many options and you have to consider if the retained solution always
do what you expect. For instance, if your data contains products as "AAPEZZGBTT" they will match
the condition 'like "%PE%GB%". If you want to check precisely that the string is "PE" followed by
two digits followed by "GB", you can use a regexp as follows :
data want;
set have;
where prxmatch("/^PE\d{2}GB$/", trim(cd_produit));
run;
See Maxim 4.
Try It.
Create fake data:
data have;
input cd_produit $;
datalines;
PE01GB
PE33GB
PE67GB
XXXXXX
;
and run your SQL on it.
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: