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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.